Suspended threads shouldn't acquire synchronization objects

Peter Hunnisett peter at transgaming.com
Mon Feb 24 13:02:57 CST 2003


ReWind licensed patch.


Peter Hunnisett <peter at transgaming.com>
Suspended threads should not acquire synchronization objects
-------------- next part --------------
? suspend_threads_no_locks.diff
? suspend_wine.diff
? server/diff
Index: server/process.c
===================================================================
RCS file: /home/wine/wine/server/process.c,v
retrieving revision 1.97
diff -u -r1.97 process.c
--- server/process.c	19 Feb 2003 00:33:33 -0000	1.97
+++ server/process.c	24 Feb 2003 19:02:49 -0000
@@ -659,7 +659,11 @@
         while (thread)
         {
             struct thread *next = thread->proc_next;
-            if (!thread->suspend) continue_thread( thread );
+            if (!thread->suspend)
+            {
+                continue_thread( thread );
+                wake_thread( thread );
+            }
             thread = next;
         }
     }
Index: server/thread.c
===================================================================
RCS file: /home/wine/wine/server/thread.c,v
retrieving revision 1.89
diff -u -r1.89 thread.c
--- server/thread.c	19 Feb 2003 00:33:33 -0000	1.89
+++ server/thread.c	24 Feb 2003 19:02:49 -0000
@@ -405,6 +405,9 @@
     struct thread_wait *wait = thread->wait;
     struct wait_queue_entry *entry = wait->queues;
 
+    /* Suspended threads may not acquire locks */
+    if( thread->process->suspend + thread->suspend > 0 ) return -1;
+
     assert( wait );
     if (wait->flags & SELECT_ALL)
     {
@@ -467,7 +470,7 @@
 
 /* attempt to wake up a thread */
 /* return >0 if OK, 0 if the wait condition is still not satisfied */
-static int wake_thread( struct thread *thread )
+int wake_thread( struct thread *thread )
 {
     int signaled, count;
     void *cookie;
@@ -941,7 +944,10 @@
     if ((thread = get_thread_from_handle( req->handle, THREAD_SUSPEND_RESUME )))
     {
         if (thread->state == TERMINATED) set_error( STATUS_ACCESS_DENIED );
-        else reply->count = resume_thread( thread );
+        else {
+          reply->count = resume_thread( thread );
+          if( reply->count == 1 ) wake_thread( thread );
+        }
         release_object( thread );
     }
 }
Index: server/thread.h
===================================================================
RCS file: /home/wine/wine/server/thread.h,v
retrieving revision 1.44
diff -u -r1.44 thread.h
--- server/thread.h	19 Feb 2003 00:33:33 -0000	1.44
+++ server/thread.h	24 Feb 2003 19:02:49 -0000
@@ -114,6 +114,7 @@
 extern struct thread *get_thread_from_pid( int pid );
 extern int suspend_thread( struct thread *thread, int check_limit );
 extern int resume_thread( struct thread *thread );
+extern int wake_thread( struct thread *thread );
 extern int add_queue( struct object *obj, struct wait_queue_entry *entry );
 extern void remove_queue( struct object *obj, struct wait_queue_entry *entry );
 extern void kill_thread( struct thread *thread, int violent_death );


More information about the wine-patches mailing list