Module: wine Branch: master Commit: 349eba9e0944c24cfd6623f063b84a05adba6dcb URL: http://source.winehq.org/git/wine.git/?a=commit;h=349eba9e0944c24cfd6623f063...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Feb 1 16:22:53 2010 +0100
server: Make terminate_process more robust against recursive calls for the same process.
---
server/process.c | 18 ++++++------------ 1 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/server/process.c b/server/process.c index 379bec6..e4dca68 100644 --- a/server/process.c +++ b/server/process.c @@ -562,23 +562,17 @@ static void process_unload_dll( struct process *process, mod_handle_t base ) /* terminate a process with the given exit code */ static void terminate_process( struct process *process, struct thread *skip, int exit_code ) { - struct list *ptr; - - if (skip && skip->process == process) /* move it to the end of the list */ - { - assert( skip->state != TERMINATED ); - list_remove( &skip->proc_entry ); - list_add_tail( &process->thread_list, &skip->proc_entry ); - } + struct thread *thread;
grab_object( process ); /* make sure it doesn't get freed when threads die */ - while ((ptr = list_head( &process->thread_list ))) +restart: + LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry ) { - struct thread *thread = LIST_ENTRY( ptr, struct thread, proc_entry ); - if (exit_code) thread->exit_code = exit_code; - if (thread == skip) break; + if (thread == skip) continue; + if (thread->state == TERMINATED) continue; kill_thread( thread, 1 ); + goto restart; } release_object( process ); }