Author: cazfi
Date: Fri Jan 29 09:02:19 2016
New Revision: 31672

URL: http://svn.gna.org/viewcvs/freeciv?rev=31672&view=rev
Log:
Always use Windows-specific server launching code on the client when 
WIN32_NATIVE is set,
no matter if HAVE_WOKING_FORK is also set.

See patch #6869

Modified:
    trunk/client/connectdlg_common.c

Modified: trunk/client/connectdlg_common.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/connectdlg_common.c?rev=31672&r1=31671&r2=31672&view=diff
==============================================================================
--- trunk/client/connectdlg_common.c    (original)
+++ trunk/client/connectdlg_common.c    Fri Jan 29 09:02:19 2016
@@ -71,7 +71,13 @@
 #define WAIT_BETWEEN_TRIES 100000 /* usecs */ 
 #define NUMBER_OF_TRIES 500
 
-#ifdef HAVE_WORKING_FORK
+#if defined(HAVE_WORKING_FORK) && !defined(WIN32_NATIVE)
+/* We are yet to see WIN32_NATIVE setup where even HAVE_WORKING_FORK would
+ * mean fork() that actually works for us. */
+#define HAVE_USABLE_FORK
+#endif
+
+#ifdef HAVE_USABLE_FORK
 static pid_t server_pid = -1;
 #elif WIN32_NATIVE
 HANDLE server_process = INVALID_HANDLE_VALUE;
@@ -113,7 +119,7 @@
 **************************************************************************/ 
 bool is_server_running(void)
 {
-#ifdef HAVE_WORKING_FORK
+#ifdef HAVE_USABLE_FORK
   return (server_pid > 0);
 #elif WIN32_NATIVE
   return (server_process != INVALID_HANDLE_VALUE);
@@ -154,7 +160,7 @@
        * 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 HAVE_WORKING_FORK
+#ifdef HAVE_USABLE_FORK
       server_pid = -1;
 #elif WIN32_NATIVE
       server_process = INVALID_HANDLE_VALUE;
@@ -164,7 +170,7 @@
       /* 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 HAVE_WORKING_FORK
+#ifdef HAVE_USABLE_FORK
       kill(server_pid, SIGTERM);
       waitpid(server_pid, NULL, WUNTRACED);
       server_pid = -1; 
@@ -176,7 +182,7 @@
       }
       server_process = INVALID_HANDLE_VALUE;
       loghandle = INVALID_HANDLE_VALUE;
-#endif /* WIN32_NATIVE || HAVE_WORKING_FORK */
+#endif /* WIN32_NATIVE || HAVE_USABLE_FORK */
     }
   }
   client_has_hack = FALSE;
@@ -188,13 +194,13 @@
 *****************************************************************/ 
 bool client_start_server(void)
 {
-#if !defined(HAVE_WORKING_FORK) && !defined(WIN32_NATIVE)
+#if !defined(HAVE_USABLE_FORK) && !defined(WIN32_NATIVE)
   /* Can't do much without fork */
   return FALSE;
-#else /* HAVE_WORKING_FORK || WIN32_NATIVE */
+#else /* HAVE_USABLE_FORK || WIN32_NATIVE */
   char buf[512];
   int connect_tries = 0;
-#if !defined(HAVE_WORKING_FORK)
+#if !defined(HAVE_USABLE_FORK)
   /* Above also implies that this is WIN32_NATIVE ->
    * Win32 that can't use fork() */
   STARTUPINFO si;
@@ -214,7 +220,7 @@
   char savefilecmdline[512];
   char savescmdline[512];
   char scenscmdline[512];
-#endif /* !HAVE_WORKING_FORK -> WIN32_NATIVE */
+#endif /* !HAVE_USABLE_FORK -> WIN32_NATIVE */
 
 #ifdef FREECIV_IPV6_SUPPORT
   enum fc_addr_family family = FC_ADDR_ANY;
@@ -243,7 +249,7 @@
     return FALSE;
   }
 
-#ifdef HAVE_WORKING_FORK
+#ifdef HAVE_USABLE_FORK
   {
     int argc = 0;
     const int max_nargs = 18;
@@ -343,7 +349,7 @@
       _exit(1);
     } 
   }
-#else /* HAVE_WORKING_FORK */
+#else /* HAVE_USABLE_FORK */
 #ifdef WIN32_NATIVE
   if (logfile) {
     loghandle = CreateFile(logfile, GENERIC_WRITE,
@@ -445,19 +451,19 @@
   server_process = pi.hProcess;
 
 #endif /* WIN32_NATIVE */
-#endif /* HAVE_WORKING_FORK */
+#endif /* HAVE_USABLE_FORK */
 
   /* a reasonable number of tries */ 
   while (connect_to_server(user_name, "localhost", internal_server_port, 
                            buf, sizeof(buf)) == -1) {
     fc_usleep(WAIT_BETWEEN_TRIES);
-#ifdef HAVE_WORKING_FORK
+#ifdef HAVE_USABLE_FORK
 #ifndef WIN32_NATIVE
     if (waitpid(server_pid, NULL, WNOHANG) != 0) {
       break;
     }
 #endif /* WIN32_NATIVE */
-#endif /* HAVE_WORKING_FORK */
+#endif /* HAVE_USABLE_FORK */
     if (connect_tries++ > NUMBER_OF_TRIES) {
       log_error("Last error from connect attempts: '%s'", buf);
       break;
@@ -513,7 +519,7 @@
   }
 
   return TRUE;
-#endif /* HAVE_WORKING_FORK || WIN32_NATIVE */
+#endif /* HAVE_USABLE_FORK || WIN32_NATIVE */
 }
 
 /*************************************************************************


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

Reply via email to