Jinoh Kang : server: Generalise async completion callback to be called on synchronous failure.

Alexandre Julliard julliard at winehq.org
Fri Mar 25 15:28:09 CDT 2022


Module: wine
Branch: master
Commit: 5d98ffe982b3b0ad72dfc938bfbe5bee7e210dcb
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=5d98ffe982b3b0ad72dfc938bfbe5bee7e210dcb

Author: Jinoh Kang <jinoh.kang.kr at gmail.com>
Date:   Thu Mar 24 02:25:04 2022 +0900

server: Generalise async completion callback to be called on synchronous failure.

Today, async_set_completion_callback() is used to register a function
that is called when the async I/O is completed.  It is assumed that the
async will eventually be queued when such callback is registered.

However, this incurs extra complexity in future code that needs the
completion logic to be invoked even if the async is never actually
queued (e.g. when the I/O failed synchronously before async_handoff).

Generalise async completion callback by calling it in async_handoff()
when the I/O status indicates failure.

Signed-off-by: Jinoh Kang <jinoh.kang.kr at gmail.com>
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 server/async.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/server/async.c b/server/async.c
index a92798fcd39..a4c9090fa73 100644
--- a/server/async.c
+++ b/server/async.c
@@ -322,6 +322,13 @@ void async_wake_obj( struct async *async )
     }
 }
 
+static void async_call_completion_callback( struct async *async )
+{
+    if (async->completion_callback)
+        async->completion_callback( async->completion_callback_private );
+    async->completion_callback = NULL;
+}
+
 /* return async object status and wait handle to client */
 obj_handle_t async_handoff( struct async *async, data_size_t *result, int force_blocking )
 {
@@ -363,6 +370,8 @@ obj_handle_t async_handoff( struct async *async, data_size_t *result, int force_
 
     if (!async->pending && NT_ERROR( get_error() ))
     {
+        async_call_completion_callback( async );
+
         close_handle( async->thread->process, async->wait_handle );
         async->wait_handle = 0;
         return 0;
@@ -528,9 +537,7 @@ void async_set_result( struct object *obj, unsigned int status, apc_param_t tota
             wake_up( &async->obj, 0 );
         }
 
-        if (async->completion_callback)
-            async->completion_callback( async->completion_callback_private );
-        async->completion_callback = NULL;
+        async_call_completion_callback( async );
 
         if (async->queue)
         {




More information about the wine-cvs mailing list