Module: wine Branch: master Commit: 48b74b32379847584294bed4ec66eb759e200f47 URL: http://source.winehq.org/git/wine.git/?a=commit;h=48b74b32379847584294bed4ec...
Author: Alexandre Julliard julliard@winehq.org Date: Fri Dec 29 16:53:33 2006 +0100
server: Split get_thread_from_pid to allow lookups by tid or pid only.
---
server/ptrace.c | 7 ++++++- server/thread.c | 14 +++++++++++--- server/thread.h | 1 + 3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/server/ptrace.c b/server/ptrace.c index 26a4042..c7aa088 100644 --- a/server/ptrace.c +++ b/server/ptrace.c @@ -144,7 +144,12 @@ void sigchld_callback(void) for (;;) { if (!(pid = wait4_wrapper( -1, &status, WUNTRACED | WNOHANG, NULL ))) break; - if (pid != -1) handle_child_status( get_thread_from_pid(pid), pid, status, -1 ); + if (pid != -1) + { + struct thread *thread = get_thread_from_tid( pid ); + if (!thread) thread = get_thread_from_pid( pid ); + handle_child_status( thread, pid, status, -1 ); + } else break; } } diff --git a/server/thread.c b/server/thread.c index 05cf3cd..47367d3 100644 --- a/server/thread.c +++ b/server/thread.c @@ -297,15 +297,23 @@ struct thread *get_thread_from_handle( o access, &thread_ops ); }
-/* find a thread from a Unix pid */ -struct thread *get_thread_from_pid( int pid ) +/* find a thread from a Unix tid */ +struct thread *get_thread_from_tid( int tid ) { struct thread *thread;
LIST_FOR_EACH_ENTRY( thread, &thread_list, struct thread, entry ) { - if (thread->unix_tid == pid) return thread; + if (thread->unix_tid == tid) return thread; } + return NULL; +} + +/* find a thread from a Unix pid */ +struct thread *get_thread_from_pid( int pid ) +{ + struct thread *thread; + LIST_FOR_EACH_ENTRY( thread, &thread_list, struct thread, entry ) { if (thread->unix_pid == pid) return thread; diff --git a/server/thread.h b/server/thread.h index 61911cd..0fc162f 100644 --- a/server/thread.h +++ b/server/thread.h @@ -103,6 +103,7 @@ extern struct thread *current; extern struct thread *create_thread( int fd, struct process *process ); extern struct thread *get_thread_from_id( thread_id_t id ); extern struct thread *get_thread_from_handle( obj_handle_t handle, unsigned int access ); +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 int wake_thread( struct thread *thread );