From: Rémi Bernon rbernon@codeweavers.com
--- server/thread.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/server/thread.c b/server/thread.c index ffc016bfa56..f3afcc33d2f 100644 --- a/server/thread.c +++ b/server/thread.c @@ -922,8 +922,6 @@ int resume_thread( struct thread *thread ) /* add a thread to an object wait queue; return 1 if OK, 0 on error */ int add_queue( struct object *obj, struct wait_queue_entry *entry ) { - grab_object( obj ); - entry->obj = obj; list_add_tail( &obj->wait_queue, &entry->entry ); return 1; } @@ -932,7 +930,6 @@ int add_queue( struct object *obj, struct wait_queue_entry *entry ) void remove_queue( struct object *obj, struct wait_queue_entry *entry ) { list_remove( &entry->entry ); - release_object( obj ); }
struct thread *get_wait_queue_thread( struct wait_queue_entry *entry ) @@ -987,7 +984,11 @@ static unsigned int end_wait( struct thread *thread, unsigned int status ) if (wait->abandoned) status += STATUS_ABANDONED_WAIT_0; } for (i = 0, entry = wait->queues; i < wait->count; i++, entry++) + { entry->obj->ops->remove_queue( entry->obj, entry ); + release_object( entry->obj ); + entry->obj = NULL; + } if (wait->user) remove_timeout_user( wait->user ); free( wait ); return status; @@ -1024,6 +1025,7 @@ static int wait_on( const union select_op *select_op, unsigned int count, struct return 0; }
+ grab_object( (entry->obj = obj) ); if (obj == (struct object *)current->queue) idle = 1; }