Commit 5d98ffe9 authored by Jinoh Kang's avatar Jinoh Kang Committed by Alexandre Julliard

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: 's avatarJinoh Kang <jinoh.kang.kr@gmail.com> Signed-off-by: 's avatarZebediah Figura <zfigura@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent f04b1024
...@@ -322,6 +322,13 @@ void async_wake_obj( struct async *async ) ...@@ -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 */ /* return async object status and wait handle to client */
obj_handle_t async_handoff( struct async *async, data_size_t *result, int force_blocking ) 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_ ...@@ -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() )) if (!async->pending && NT_ERROR( get_error() ))
{ {
async_call_completion_callback( async );
close_handle( async->thread->process, async->wait_handle ); close_handle( async->thread->process, async->wait_handle );
async->wait_handle = 0; async->wait_handle = 0;
return 0; return 0;
...@@ -528,9 +537,7 @@ void async_set_result( struct object *obj, unsigned int status, apc_param_t tota ...@@ -528,9 +537,7 @@ void async_set_result( struct object *obj, unsigned int status, apc_param_t tota
wake_up( &async->obj, 0 ); wake_up( &async->obj, 0 );
} }
if (async->completion_callback) async_call_completion_callback( async );
async->completion_callback( async->completion_callback_private );
async->completion_callback = NULL;
if (async->queue) if (async->queue)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment