Author: cazfi Date: Wed Jan 27 03:18:48 2016 New Revision: 31622 URL: http://svn.gna.org/viewcvs/freeciv?rev=31622&view=rev Log: Fixed compilation in a case where both HAVE_WORKING_FORK and WIN32_NATIVE are true.
See bug #24293 Modified: branches/S2_5/client/connectdlg_common.c Modified: branches/S2_5/client/connectdlg_common.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/connectdlg_common.c?rev=31622&r1=31621&r2=31622&view=diff ============================================================================== --- branches/S2_5/client/connectdlg_common.c (original) +++ branches/S2_5/client/connectdlg_common.c Wed Jan 27 03:18:48 2016 @@ -72,12 +72,12 @@ #define WAIT_BETWEEN_TRIES 100000 /* usecs */ #define NUMBER_OF_TRIES 500 - -#ifdef WIN32_NATIVE + +#ifdef HAVE_WORKING_FORK +static pid_t server_pid = -1; +#elif WIN32_NATIVE HANDLE server_process = INVALID_HANDLE_VALUE; HANDLE loghandle = INVALID_HANDLE_VALUE; -#else -static pid_t server_pid = - 1; #endif static char challenge_fullname[MAX_LEN_PATH]; @@ -113,12 +113,14 @@ /************************************************************************** Tests if the client has started the server. **************************************************************************/ -bool is_server_running() -{ -#ifdef WIN32_NATIVE +bool is_server_running(void) +{ +#ifdef HAVE_WORKING_FORK + return (server_pid > 0); +#elif WIN32_NATIVE return (server_process != INVALID_HANDLE_VALUE); -#else - return (server_pid > 0); +#else + return FALSE; /* We've been unable to start one! */ #endif } @@ -154,17 +156,21 @@ * it could potentially be called when we're connected to an unowned * server. In this case we don't want to kill it. */ send_chat("/quit"); -#ifdef WIN32_NATIVE +#ifdef HAVE_WORKING_FORK + server_pid = -1; +#elif WIN32_NATIVE server_process = INVALID_HANDLE_VALUE; loghandle = INVALID_HANDLE_VALUE; -#else - server_pid = -1; #endif } else if (force) { /* Either we already disconnected, or we didn't get control of the * server. In either case, the only thing to do is a "hard" kill of * the server. */ -#ifdef WIN32_NATIVE +#ifdef HAVE_WORKING_FORK + kill(server_pid, SIGTERM); + waitpid(server_pid, NULL, WUNTRACED); + server_pid = -1; +#elif WIN32_NATIVE TerminateProcess(server_process, 0); CloseHandle(server_process); if (loghandle != INVALID_HANDLE_VALUE) { @@ -172,10 +178,6 @@ } server_process = INVALID_HANDLE_VALUE; loghandle = INVALID_HANDLE_VALUE; -#elif HAVE_WORKING_FORK - kill(server_pid, SIGTERM); - waitpid(server_pid, NULL, WUNTRACED); - server_pid = -1; #endif /* WIN32_NATIVE || HAVE_WORKING_FORK */ } } @@ -194,7 +196,9 @@ #else /* HAVE_WORKING_FORK || WIN32_NATIVE */ char buf[512]; int connect_tries = 0; -# ifdef WIN32_NATIVE +#if !defined(HAVE_WORKING_FORK) + /* Above also implies that this is WIN32_NATIVE -> + * Win32 that can't use fork() */ STARTUPINFO si; PROCESS_INFORMATION pi; @@ -212,7 +216,7 @@ char savefilecmdline[512]; char savescmdline[512]; char scenscmdline[512]; -# endif /* WIN32_NATIVE */ +#endif /* !HAVE_WORKING_FORK -> WIN32_NATIVE */ #ifdef IPV6_SUPPORT enum fc_addr_family family = FC_ADDR_ANY; @@ -241,7 +245,7 @@ return FALSE; } -# ifdef HAVE_WORKING_FORK +#ifdef HAVE_WORKING_FORK { int argc = 0; const int max_nargs = 18; @@ -340,8 +344,8 @@ _exit(1); } } -# else /* HAVE_WORKING_FORK */ -# ifdef WIN32_NATIVE +#else /* HAVE_WORKING_FORK */ +#ifdef WIN32_NATIVE if (logfile) { loghandle = CreateFile(logfile, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, @@ -441,9 +445,9 @@ server_process = pi.hProcess; -# endif /* WIN32_NATIVE */ -# endif /* HAVE_WORKING_FORK */ - +#endif /* WIN32_NATIVE */ +#endif /* HAVE_WORKING_FORK */ + /* a reasonable number of tries */ while (connect_to_server(user_name, "localhost", internal_server_port, buf, sizeof(buf)) == -1) { _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits