From: Rémi Bernon rbernon@codeweavers.com
--- server/thread.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-)
diff --git a/server/thread.c b/server/thread.c index 5100045b7f2..6f99b8c0415 100644 --- a/server/thread.c +++ b/server/thread.c @@ -85,6 +85,7 @@ struct thread_wait struct thread_apc { struct object obj; /* object header */ + struct event *sync; /* event object as sync */ struct list entry; /* queue linked list */ struct thread *caller; /* thread that queued this apc */ struct object *owner; /* object that queued this apc */ @@ -95,19 +96,9 @@ struct thread_apc
static void dump_thread_apc( struct object *obj, int verbose ); static struct sync *thread_apc_get_sync( struct object *obj ); -static int thread_apc_signaled( struct object *obj, struct wait_queue_entry *entry ); static void thread_apc_destroy( struct object *obj ); static void clear_apc_queue( struct list *queue );
-static const struct sync_ops thread_apc_sync_ops = -{ - add_queue, /* add_queue */ - remove_queue, /* remove_queue */ - thread_apc_signaled, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ -}; - static const struct object_ops thread_apc_ops = { sizeof(struct thread_apc), /* size */ @@ -693,13 +684,7 @@ static struct sync *thread_apc_get_sync( struct object *obj ) { struct thread_apc *apc = (struct thread_apc *)obj; assert( obj->ops == &thread_apc_ops ); - return &apc->obj.sync; -} - -static int thread_apc_signaled( struct object *obj, struct wait_queue_entry *entry ) -{ - struct thread_apc *apc = (struct thread_apc *)obj; - return apc->executed; + return get_event_sync( apc->sync ); }
static void thread_apc_destroy( struct object *obj ) @@ -715,6 +700,7 @@ static void thread_apc_destroy( struct object *obj ) async_set_result( apc->owner, apc->call.async_io.status, 0 ); release_object( apc->owner ); } + release_object( apc->sync ); }
/* queue an async procedure call */ @@ -724,7 +710,7 @@ static struct thread_apc *create_apc( struct object *owner, const union apc_call
if ((apc = alloc_object( &thread_apc_ops ))) { - apc->obj.sync.ops = &thread_apc_sync_ops; + apc->sync = create_event_sync( 1, 0 ); if (call_data) apc->call = *call_data; else apc->call.type = APC_NONE; apc->caller = NULL; @@ -1486,7 +1472,7 @@ void thread_cancel_apc( struct thread *thread, struct object *owner, enum apc_ty if (apc->owner != owner) continue; list_remove( &apc->entry ); apc->executed = 1; - wake_up( &apc->obj, 0 ); + set_event( apc->sync ); release_object( apc ); return; } @@ -1516,7 +1502,7 @@ static void clear_apc_queue( struct list *queue ) struct thread_apc *apc = LIST_ENTRY( ptr, struct thread_apc, entry ); list_remove( &apc->entry ); apc->executed = 1; - wake_up( &apc->obj, 0 ); + set_event( apc->sync ); release_object( apc ); } } @@ -1976,7 +1962,7 @@ DECL_HANDLER(select) apc->result.create_thread.handle = handle; clear_error(); /* ignore errors from the above calls */ } - wake_up( &apc->obj, 0 ); + set_event( apc->sync ); close_handle( current->process, req->prev_apc ); release_object( apc ); } @@ -1999,7 +1985,7 @@ DECL_HANDLER(select) else { apc->executed = 1; - wake_up( &apc->obj, 0 ); + set_event( apc->sync ); } release_object( apc ); }