Alexandre Julliard : server: Restart at the head of the wait queue when we woke a thread, since this can modify the queue.

Alexandre Julliard julliard at winehq.org
Mon Jun 15 07:59:03 CDT 2009


Module: wine
Branch: master
Commit: fd78e6e3a51091a8cbe049237a55347390d9570b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=fd78e6e3a51091a8cbe049237a55347390d9570b

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Sat Jun 13 12:20:49 2009 +0200

server: Restart at the head of the wait queue when we woke a thread, since this can modify the queue.

---

 server/thread.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/server/thread.c b/server/thread.c
index e931e81..2ea8929 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -712,15 +712,15 @@ done:
 /* attempt to wake threads sleeping on the object wait queue */
 void wake_up( struct object *obj, int max )
 {
-    struct list *ptr, *next;
+    struct list *ptr;
 
-    LIST_FOR_EACH_SAFE( ptr, next, &obj->wait_queue )
+    LIST_FOR_EACH( ptr, &obj->wait_queue )
     {
         struct wait_queue_entry *entry = LIST_ENTRY( ptr, struct wait_queue_entry, entry );
-        if (wake_thread( entry->thread ))
-        {
-            if (max && !--max) break;
-        }
+        if (!wake_thread( entry->thread )) continue;
+        if (max && !--max) break;
+        /* restart at the head of the list since a wake up can change the object wait queue */
+        ptr = &obj->wait_queue;
     }
 }
 




More information about the wine-cvs mailing list