[Wine-patches] [eter-2.1 1/2] server: Make it possible to deliver an APC to any alive thread in the process. (eterbug #12211)

Dmitry Timoshkov dtimoshkov на etersoft.ru
Вт Ноя 14 05:15:19 MSK 2017


---
 server/async.c  | 4 ++--
 server/thread.c | 7 +++++--
 server/thread.h | 2 +-
 server/timer.c  | 2 +-
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/server/async.c b/server/async.c
index ccddec76a6..29d9a83e52 100644
--- a/server/async.c
+++ b/server/async.c
@@ -162,7 +162,7 @@ void async_terminate( struct async *async, unsigned int status )
     data.async_io.user   = async->data.arg;
     data.async_io.sb     = async->data.iosb;
     data.async_io.status = status;
-    thread_queue_apc( async->thread, &async->obj, &data );
+    thread_queue_apc( NULL, async->thread, &async->obj, &data );
     async->status = status;
     async_reselect( async );
     release_object( async );  /* so that it gets destroyed when the async is done */
@@ -296,7 +296,7 @@ void async_set_result( struct object *obj, unsigned int status, unsigned int tot
             data.user.args[0] = async->data.arg;
             data.user.args[1] = async->data.iosb;
             data.user.args[2] = 0;
-            thread_queue_apc( async->thread, NULL, &data );
+            thread_queue_apc( NULL, async->thread, NULL, &data );
         }
         if (async->event) set_event( async->event );
         else if (async->queue->fd) set_fd_signaled( async->queue->fd, 1 );
diff --git a/server/thread.c b/server/thread.c
index fdbc144b36..380617e3aa 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -808,6 +808,9 @@ static int queue_apc( struct process *process, struct thread *thread, struct thr
 {
     struct list *queue;
 
+    if (thread && thread->state == TERMINATED && process)
+        thread = NULL;
+
     if (!thread)  /* find a suitable thread inside the process */
     {
         struct thread *candidate;
@@ -859,14 +862,14 @@ static int queue_apc( struct process *process, struct thread *thread, struct thr
 }
 
 /* queue an async procedure call */
-int thread_queue_apc( struct thread *thread, struct object *owner, const apc_call_t *call_data )
+int thread_queue_apc( struct process *process, struct thread *thread, struct object *owner, const apc_call_t *call_data )
 {
     struct thread_apc *apc;
     int ret = 0;
 
     if ((apc = create_apc( owner, call_data )))
     {
-        ret = queue_apc( NULL, thread, apc );
+        ret = queue_apc( process, thread, apc );
         release_object( apc );
     }
     return ret;
diff --git a/server/thread.h b/server/thread.h
index 1c4a74a644..3ae0ed7fb3 100644
--- a/server/thread.h
+++ b/server/thread.h
@@ -113,7 +113,7 @@ extern void remove_queue( struct object *obj, struct wait_queue_entry *entry );
 extern void kill_thread( struct thread *thread, int violent_death );
 extern void break_thread( struct thread *thread );
 extern void wake_up( struct object *obj, int max );
-extern int thread_queue_apc( struct thread *thread, struct object *owner, const apc_call_t *call_data );
+extern int thread_queue_apc( struct process *process, struct thread *thread, struct object *owner, const apc_call_t *call_data );
 extern void thread_cancel_apc( struct thread *thread, struct object *owner, enum apc_type type );
 extern int thread_add_inflight_fd( struct thread *thread, int client, int server );
 extern int thread_get_inflight_fd( struct thread *thread, int client );
diff --git a/server/timer.c b/server/timer.c
index b38eae71db..4d2bb31608 100644
--- a/server/timer.c
+++ b/server/timer.c
@@ -120,7 +120,7 @@ static void timer_callback( void *private )
         }
         else data.type = APC_NONE;  /* wake up only */
 
-        if (!thread_queue_apc( timer->thread, &timer->obj, &data ))
+        if (!thread_queue_apc( NULL, timer->thread, &timer->obj, &data ))
         {
             release_object( timer->thread );
             timer->thread = NULL;
-- 
2.15.0



Подробная информация о списке рассылки Wine-patches