From: Rémi Bernon rbernon@codeweavers.com
--- server/protocol.def | 2 +- server/queue.c | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/server/protocol.def b/server/protocol.def index 97b4805c552..70cd835b647 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -915,7 +915,7 @@ typedef volatile struct
typedef volatile struct { - int placeholder; + obj_handle_t handle; /* handle to the queue */ } queue_shm_t;
typedef volatile union diff --git a/server/queue.c b/server/queue.c index 5f4e5fa33c2..d56b199f1f0 100644 --- a/server/queue.c +++ b/server/queue.c @@ -290,6 +290,7 @@ static struct msg_queue *create_msg_queue( struct thread *thread, struct thread_ { struct thread_input *new_input = NULL; struct msg_queue *queue; + obj_handle_t handle; int i;
if (!input) @@ -328,6 +329,13 @@ static struct msg_queue *create_msg_queue( struct thread *thread, struct thread_ return NULL; }
+ handle = alloc_handle( thread->process, queue, SYNCHRONIZE, 0 ); + SHARED_WRITE_BEGIN( queue->shared, queue_shm_t ) + { + shared->handle = handle; + } + SHARED_WRITE_END; + thread->queue = queue; } if (new_input) release_object( new_input ); @@ -337,8 +345,19 @@ static struct msg_queue *create_msg_queue( struct thread *thread, struct thread_ /* free the message queue of a thread at thread exit */ void free_msg_queue( struct thread *thread ) { + obj_handle_t handle; + remove_thread_hooks( thread ); if (!thread->queue) return; + + SHARED_WRITE_BEGIN( thread->queue->shared, queue_shm_t ) + { + handle = shared->handle; + shared->handle = 0; + } + SHARED_WRITE_END; + close_handle( thread->process, handle ); + release_object( thread->queue ); thread->queue = NULL; } @@ -2866,7 +2885,7 @@ DECL_HANDLER(get_msg_queue) struct msg_queue *queue = get_current_queue();
reply->handle = 0; - if (queue) reply->handle = alloc_handle( current->process, queue, SYNCHRONIZE, 0 ); + if (queue) reply->handle = queue->shared->handle; }