From 31022d66ca61f7bb5dab6b597b0f4532226f3175 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 16 Aug 2002 23:30:41 +0000 Subject: [PATCH] Signal and release the idle event when the process main thread exits. --- server/queue.c | 21 +++++++++++++++++++++ server/thread.c | 12 +----------- server/user.h | 1 + 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/server/queue.c b/server/queue.c index ae2486ecd9e..e250faecb4e 100644 --- a/server/queue.c +++ b/server/queue.c @@ -163,6 +163,27 @@ static struct msg_queue *create_msg_queue( struct thread *thread ) return queue; } +/* free the message queue of a thread at thread exit */ +void free_msg_queue( struct thread *thread ) +{ + struct process *process = thread->process; + + if (!thread->queue) return; + if (process->queue == thread->queue) /* is it the process main queue? */ + { + release_object( process->queue ); + process->queue = NULL; + if (process->idle_event) + { + set_event( process->idle_event ); + release_object( process->idle_event ); + process->idle_event = NULL; + } + } + release_object( thread->queue ); + thread->queue = NULL; +} + /* check the queue status */ inline static int is_signaled( struct msg_queue *queue ) { diff --git a/server/thread.c b/server/thread.c index bc0833c8a26..b5a95becf57 100644 --- a/server/thread.c +++ b/server/thread.c @@ -187,16 +187,7 @@ static void cleanup_thread( struct thread *thread ) if (thread->request_fd != -1) close( thread->request_fd ); if (thread->reply_fd != -1) close( thread->reply_fd ); if (thread->wait_fd != -1) close( thread->wait_fd ); - if (thread->queue) - { - if (thread->process->queue == thread->queue) - { - release_object( thread->process->queue ); - thread->process->queue = NULL; - } - release_object( thread->queue ); - thread->queue = NULL; - } + free_msg_queue( thread ); destroy_thread_windows( thread ); for (i = 0; i < MAX_INFLIGHT_FDS; i++) { @@ -795,7 +786,6 @@ DECL_HANDLER(new_thread) return; } kill_thread( thread, 1 ); - request_fd = -1; } } diff --git a/server/user.h b/server/user.h index f3e10604a13..6d5766e6024 100644 --- a/server/user.h +++ b/server/user.h @@ -43,6 +43,7 @@ extern void *next_user_handle( user_handle_t *handle, enum user_object type ); /* queue functions */ +extern void free_msg_queue( struct thread *thread ); extern void inc_queue_paint_count( struct thread *thread, int incr ); extern void queue_cleanup_window( struct thread *thread, user_handle_t win ); extern void post_message( user_handle_t win, unsigned int message,