Author: cazfi Date: Sat Oct 17 16:26:21 2015 New Revision: 30111 URL: http://svn.gna.org/viewcvs/freeciv?rev=30111&view=rev Log: Added error logging about server spawning failures.
See patch #6435 Modified: trunk/client/clinet.c trunk/client/connectdlg_common.c trunk/utility/netintf.c Modified: trunk/client/clinet.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/clinet.c?rev=30111&r1=30110&r2=30111&view=diff ============================================================================== --- trunk/client/clinet.c (original) +++ trunk/client/clinet.c Sat Oct 17 16:26:21 2015 @@ -248,6 +248,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: trunk/client/connectdlg_common.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/connectdlg_common.c?rev=30111&r1=30110&r2=30111&view=diff ============================================================================== --- trunk/client/connectdlg_common.c (original) +++ trunk/client/connectdlg_common.c Sat Oct 17 16:26:21 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...")); @@ -390,15 +390,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 @@ -416,11 +416,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; @@ -439,6 +448,7 @@ #endif /* WIN32_NATIVE */ #endif /* HAVE_WORKING_FORK */ if (connect_tries++ > NUMBER_OF_TRIES) { + log_error("Last error from connect attempts: '%s'", buf); break; } } @@ -449,11 +459,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: trunk/utility/netintf.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/utility/netintf.c?rev=30111&r1=30110&r2=30111&view=diff ============================================================================== --- trunk/utility/netintf.c (original) +++ trunk/utility/netintf.c Sat Oct 17 16:26:21 2015 @@ -568,6 +568,7 @@ break; default: fc_assert(FALSE); + log_error("Port from unsupported address family requested!"); return -1; } @@ -629,7 +630,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; } @@ -648,10 +657,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