Author: cazfi
Date: Sat Oct 17 16:26:55 2015
New Revision: 30113

URL: http://svn.gna.org/viewcvs/freeciv?rev=30113&view=rev
Log:
Added error logging about server spawning failures. 

See patch #6435

Modified:
    branches/S2_5/client/clinet.c
    branches/S2_5/client/connectdlg_common.c
    branches/S2_5/utility/netintf.c

Modified: branches/S2_5/client/clinet.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/clinet.c?rev=30113&r1=30112&r2=30113&view=diff
==============================================================================
--- branches/S2_5/client/clinet.c       (original)
+++ branches/S2_5/client/clinet.c       Sat Oct 17 16:26:55 2015
@@ -255,6 +255,10 @@
 int connect_to_server(const char *username, const char *hostname, int port,
                      char *errbuf, int errbufsize)
 {
+  if (errbufsize > 0 && errbuf != NULL) {
+    errbuf[0] = '\0';
+  }
+
   if (0 != get_server_address(hostname, port, errbuf, errbufsize)) {
     return -1;
   }

Modified: branches/S2_5/client/connectdlg_common.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/connectdlg_common.c?rev=30113&r1=30112&r2=30113&view=diff
==============================================================================
--- branches/S2_5/client/connectdlg_common.c    (original)
+++ branches/S2_5/client/connectdlg_common.c    Sat Oct 17 16:26:55 2015
@@ -192,8 +192,10 @@
   char savesdir[MAX_LEN_PATH];
   char scensdir[MAX_LEN_PATH];
   char options[512];
+#ifdef DEBUG
   char cmdline1[512];
   char cmdline2[512];
+#endif /* DEBUG */
   char cmdline3[512];
   char cmdline4[512];
   char logcmdline[512];
@@ -224,8 +226,6 @@
                                              family, "localhost", TRUE);
 
   if (internal_server_port < 0) {
-    log_verbose("None of the ports %d - %d is available to start freeciv 
server on.",
-                DEFAULT_SOCK_PORT + 1, DEFAULT_SOCK_PORT + 1 + 10000);
     output_window_append(ftc_client, _("Couldn't start the server."));
     output_window_append(ftc_client,
                          _("You'll have to start one manually. Sorry..."));
@@ -389,15 +389,15 @@
               "--scenarios \"%s\" -A none",
               internal_server_port, logcmdline, scriptcmdline, savefilecmdline,
               savescmdline, scenscmdline);
+#ifdef DEBUG
   fc_snprintf(cmdline1, sizeof(cmdline1), "./fcser %s", options);
   fc_snprintf(cmdline2, sizeof(cmdline2),
               "./server/freeciv-server %s", options);
+#endif /* DEBUG */
   fc_snprintf(cmdline3, sizeof(cmdline3),
               BINDIR "/freeciv-server %s", options);
   fc_snprintf(cmdline4, sizeof(cmdline4),
               "freeciv-server %s", options);
-
-  log_verbose("Arguments to spawned server: %s", options);
 
   if (
 #ifdef DEBUG
@@ -415,11 +415,20 @@
       && !CreateProcess(NULL, cmdline4, NULL, NULL, TRUE,
                         DETACHED_PROCESS | NORMAL_PRIORITY_CLASS,
                         NULL, NULL, &si, &pi)) {
+    log_error("Failed to start server process.");
+#ifdef DEBUG
+    log_verbose("Tried with commandline: '%s'", cmdline1);
+    log_verbose("Tried with commandline: '%s'", cmdline2);
+#endif /* DEBUG */
+    log_verbose("Tried with commandline: '%s'", cmdline3);
+    log_verbose("Tried with commandline: '%s'", cmdline4);
     output_window_append(ftc_client, _("Couldn't start the server."));
     output_window_append(ftc_client,
                          _("You'll have to start one manually. Sorry..."));
     return FALSE;
   }
+
+  log_verbose("Arguments to spawned server: %s", options);
 
   server_process = pi.hProcess;
 
@@ -438,6 +447,7 @@
 #endif /* WIN32_NATIVE */
 #endif /* HAVE_WORKING_FORK */
     if (connect_tries++ > NUMBER_OF_TRIES) {
+      log_error("Last error from connect attempts: '%s'", buf);
       break;
     }
   }
@@ -448,11 +458,13 @@
     /* possible that server is still running. kill it */ 
     client_kill_server(TRUE);
 
+    log_error("Failed to connect to spawned server!");
     output_window_append(ftc_client, _("Couldn't connect to the server."));
     output_window_append(ftc_client,
                          _("We probably couldn't start it from here."));
     output_window_append(ftc_client,
                          _("You'll have to start one manually. Sorry..."));
+
     return FALSE;
   }
 

Modified: branches/S2_5/utility/netintf.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/utility/netintf.c?rev=30113&r1=30112&r2=30113&view=diff
==============================================================================
--- branches/S2_5/utility/netintf.c     (original)
+++ branches/S2_5/utility/netintf.c     Sat Oct 17 16:26:55 2015
@@ -547,6 +547,7 @@
      break;
    default:
      fc_assert(FALSE);
+     log_error("Port from unsupported address family requested!");
 
      return -1;
   }
@@ -613,7 +614,15 @@
         struct hostent *hp;
 
         hp = gethostbyname(net_interface);
-        if (!hp || hp->h_addrtype != AF_INET) {
+        if (hp == NULL) {
+          log_error("No hostent for %s!", net_interface);
+
+          return -1;
+        }
+        if (hp->h_addrtype != AF_INET) {
+          log_error("Requested IPv4 address for %s, got something else! (%d)",
+                    net_interface, hp->h_addrtype);
+
           return -1;
         }
 
@@ -632,10 +641,13 @@
   }
 
   if (!found) {
+    log_error("None of the ports %d - %d is available.",
+              starting_port, highest_port);
+
     return -1;
   }
 
-  /* Rollback the last increment from the loop, back to port
+  /* Rollback the last increment from the loop, back to the port
    * number found to be free. */
   port--;
 


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to