<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40277 >

 $subject

 This applies for program start only. It's still possible that
metaserver connection is lost later.

 This is another patch I have been using in my own pubserver for a while.


 - ML

diff -Nurd -X.diff_ignore freeciv/server/meta.c freeciv/server/meta.c
--- freeciv/server/meta.c       2008-03-08 16:56:22.000000000 +0200
+++ freeciv/server/meta.c       2008-04-25 15:25:16.000000000 +0300
@@ -411,7 +411,7 @@
 /*************************************************************************
  lookup the correct address for the metaserver.
 *************************************************************************/
-void server_open_meta(void)
+bool server_open_meta(void)
 {
   const char *path;
  
@@ -421,7 +421,7 @@
   }
   
   if (!(path = my_lookup_httpd(metaname, &metaport, srvarg.metaserver_addr))) {
-    return;
+    return FALSE;
   }
   
   metaserver_path = mystrdup(path);
@@ -430,7 +430,7 @@
     freelog(LOG_ERROR, _("Metaserver: bad address: [%s:%d]."),
             metaname, metaport);
     metaserver_failed();
-    return;
+    return FALSE;
   }
 
   if (meta_patches[0] == '\0') {
@@ -441,6 +441,8 @@
   }
 
   server_is_open = TRUE;
+
+  return TRUE;
 }
 
 /**************************************************************************
diff -Nurd -X.diff_ignore freeciv/server/meta.h freeciv/server/meta.h
--- freeciv/server/meta.h       2007-08-11 18:29:59.000000000 +0300
+++ freeciv/server/meta.h       2008-04-25 15:25:56.000000000 +0300
@@ -42,7 +42,7 @@
 char *meta_addr_port(void);
 
 void server_close_meta(void);
-void server_open_meta(void);
+bool server_open_meta(void);
 bool is_metaserver_open(void);
 
 bool send_server_info_to_metaserver(enum meta_flag flag);
diff -Nurd -X.diff_ignore freeciv/server/srv_main.c freeciv/server/srv_main.c
--- freeciv/server/srv_main.c   2008-04-23 03:13:19.000000000 +0300
+++ freeciv/server/srv_main.c   2008-04-25 15:44:23.000000000 +0300
@@ -1944,15 +1944,19 @@
     (void) load_command(NULL, srvarg.load_filename, FALSE);
   } 
 
+  maybe_automatic_meta_message(default_meta_message_string());
+
   if(!(srvarg.metaserver_no_send)) {
     freelog(LOG_NORMAL, _("Sending info to metaserver [%s]"),
            meta_addr_port());
-    server_open_meta(); /* open socket for meta server */ 
+    /* Open socket for meta server */
+    if (!server_open_meta()
+        || !send_server_info_to_metaserver(META_INFO)) {
+      con_write(C_FAIL, _("Not starting without explicitly requested 
metaserver connection."));
+      exit(EXIT_FAILURE);
+    }
   }
 
-  maybe_automatic_meta_message(default_meta_message_string());
-  (void) send_server_info_to_metaserver(META_INFO);
-
   /* accept new players, wait for serverop to start..*/
   set_server_state(S_S_INITIAL);
 
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to