CVS: winex/server process.c,1.41,1.42

[email protected] 31 Jul 2007 17:38:42 -0000
Newsgroups gmane.comp.emulators.winex.cvs
Message-ID <[email protected]>
Subject: winex/server process.c,1.41,1.42Update of /var/lib/cvsd/cvsroot/winex/server
In directory agravaine:/tmp/cvs-serv22315/server

Modified Files:
	process.c 
Log Message:

- fix wait4 timeout error seen intermittently when starting games. It was triggered by a race condition when starting a new thread marked as SCDM_INTERNAL while being debugged



Index: process.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/server/process.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- process.c	30 Mar 2007 18:58:49 -0000	1.41
+++ process.c	31 Jul 2007 17:38:40 -0000	1.42
@@ -591,7 +591,19 @@
         struct thread *thread = process->thread_list;
         for (; thread; thread = thread->proc_next)
         {
-            if (!thread->suspend || (thread->sched_mode & SCDM_INTERNAL))
+            /* - SCDM_INTERNAL threads don't actually get stopped in
+               suspend_thread(), even though "suspend" gets incremented;
+               thus we manually stop them here regardless.
+               - SCDM_CREATED_SUSPENDED (which can be set with SCDM_INTERNAL)
+               needs to be handled as a special case here due to
+               init_thread(), where we will have actually stopped the
+               thread if it is supposed to be created suspended. If we're
+               being debugged, then we'll do a suspend_process(), which
+               would otherwise try to re-suspend the thread (and then
+               afterward resume it too early) */
+            if (!thread->suspend ||
+                ((thread->sched_mode & SCDM_INTERNAL) &&
+                 !(thread->sched_mode & SCDM_CREATED_SUSPENDED)))
             {
                 if (!thread->wait && thread->unix_tid_or_pid &&
                     !(thread->sched_mode & SCDM_BLOCKED))
@@ -615,7 +627,11 @@
         struct thread *thread = process->thread_list;
         for (; thread; thread = thread->proc_next)
         {
-            if (!thread->suspend || (thread->sched_mode & SCDM_INTERNAL))
+            /* See comments in suspend_process() */
+            if (!thread->suspend ||
+                ((thread->sched_mode & SCDM_INTERNAL) &&
+                 !(thread->sched_mode & SCDM_CREATED_SUSPENDED)))
+
             {
                 continue_thread( thread );
                 if (!thread->wait && thread->unix_tid_or_pid &&