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@gmail.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jinoh Kang 2022-03-24 02:25:04 +09:00 committed by Alexandre Julliard
parent f04b102484
commit 5d98ffe982
1 changed files with 10 additions and 3 deletions

View File

@ -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)
{