From fd78e6e3a51091a8cbe049237a55347390d9570b Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sat, 13 Jun 2009 12:20:49 +0200 Subject: [PATCH] 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 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/thread.c b/server/thread.c index e931e81d093..2ea892913d4 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; } }