diff --git a/server/debugger.c b/server/debugger.c index 2ee6f6d661b..d8a390e35fc 100644 --- a/server/debugger.c +++ b/server/debugger.c @@ -308,7 +308,11 @@ static void debug_event_destroy( struct object *obj ) break; } } - if (event->sender->context == &event->context) event->sender->context = NULL; + if (event->sender->context == &event->context) + { + event->sender->context = NULL; + stop_thread_if_suspended( event->sender ); + } release_object( event->sender ); release_object( event->debugger ); } @@ -680,6 +684,7 @@ DECL_HANDLER(get_exception_status) data_size_t size = min( sizeof(context_t), get_reply_max_size() ); set_reply_data( &event->context, size ); current->context = NULL; + stop_thread_if_suspended( current ); } set_error( event->status ); } diff --git a/server/process.c b/server/process.c index 797b4cf92d8..f5430c8f52f 100644 --- a/server/process.c +++ b/server/process.c @@ -1045,7 +1045,7 @@ DECL_HANDLER(init_process_done) set_process_startup_state( process, STARTUP_DONE ); if (req->gui) process->idle_event = create_event( NULL, NULL, 0, 1, 0, NULL ); - if (current->suspend + process->suspend > 0) stop_thread( current ); + stop_thread_if_suspended( current ); if (process->debugger) set_process_debug_flag( process, 1 ); } diff --git a/server/thread.c b/server/thread.c index 9e56b1b97c0..438884785f7 100644 --- a/server/thread.c +++ b/server/thread.c @@ -491,6 +491,12 @@ void stop_thread( struct thread *thread ) if (is_process_init_done(thread->process)) send_thread_signal( thread, SIGUSR1 ); } +/* stop a thread if it's supposed to be suspended */ +void stop_thread_if_suspended( struct thread *thread ) +{ + if (thread->suspend + thread->process->suspend > 0) stop_thread( thread ); +} + /* suspend a thread */ static int suspend_thread( struct thread *thread ) { @@ -1182,7 +1188,7 @@ DECL_HANDLER(init_thread) } if (process->unix_pid != current->unix_pid) process->unix_pid = -1; /* can happen with linuxthreads */ - if (current->suspend + process->suspend > 0) stop_thread( current ); + stop_thread_if_suspended( current ); generate_debug_event( current, CREATE_THREAD_DEBUG_EVENT, &req->entry ); set_thread_affinity( current, current->affinity ); } @@ -1556,7 +1562,11 @@ DECL_HANDLER(get_suspend_context) if (current->suspend_context) { set_reply_data_ptr( current->suspend_context, sizeof(context_t) ); - if (current->context == current->suspend_context) current->context = NULL; + if (current->context == current->suspend_context) + { + current->context = NULL; + stop_thread_if_suspended( current ); + } current->suspend_context = NULL; } else set_error( STATUS_INVALID_PARAMETER ); /* not suspended, shouldn't happen */ diff --git a/server/thread.h b/server/thread.h index 1e95732d3a0..1c4a74a644a 100644 --- a/server/thread.h +++ b/server/thread.h @@ -106,6 +106,7 @@ extern struct thread *get_thread_from_handle( obj_handle_t handle, unsigned int extern struct thread *get_thread_from_tid( int tid ); extern struct thread *get_thread_from_pid( int pid ); extern void stop_thread( struct thread *thread ); +extern void stop_thread_if_suspended( struct thread *thread ); extern int wake_thread( struct thread *thread ); extern int add_queue( struct object *obj, struct wait_queue_entry *entry ); extern void remove_queue( struct object *obj, struct wait_queue_entry *entry );