mirror of
https://gitlab.winehq.org/wine/wine.git
synced 2024-11-21 17:09:06 -07:00
server: Add a helper to call async_request_complete() while allocating new memory.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
96593370cd
commit
559a8cea57
5 changed files with 20 additions and 16 deletions
|
@ -361,6 +361,21 @@ void async_request_complete( struct async *async, unsigned int status, data_size
|
|||
async_terminate( async, status );
|
||||
}
|
||||
|
||||
/* complete a request-based async */
|
||||
void async_request_complete_alloc( struct async *async, unsigned int status, data_size_t result,
|
||||
data_size_t out_size, const void *out_data )
|
||||
{
|
||||
void *out_data_copy = NULL;
|
||||
|
||||
if (out_size && !(out_data_copy = memdup( out_data, out_size )))
|
||||
{
|
||||
async_terminate( async, STATUS_NO_MEMORY );
|
||||
return;
|
||||
}
|
||||
|
||||
async_request_complete( async, status, result, out_size, out_data_copy );
|
||||
}
|
||||
|
||||
/* set the timeout of an async operation */
|
||||
void async_set_timeout( struct async *async, timeout_t timeout, unsigned int status )
|
||||
{
|
||||
|
|
|
@ -1500,12 +1500,7 @@ DECL_HANDLER(get_next_console_request)
|
|||
{
|
||||
data_size_t out_size = min( iosb->out_size, get_req_data_size() );
|
||||
data_size_t result = ioctl->code == IOCTL_CONDRV_WRITE_FILE ? iosb->in_size : out_size;
|
||||
void *out_data;
|
||||
|
||||
if (!out_size || (out_data = memdup( get_req_data(), out_size )))
|
||||
async_request_complete( async, status, result, out_size, out_data );
|
||||
else
|
||||
async_terminate( async, STATUS_NO_MEMORY );
|
||||
async_request_complete_alloc( async, status, result, out_size, get_req_data() );
|
||||
}
|
||||
|
||||
release_object( async );
|
||||
|
|
|
@ -385,12 +385,8 @@ static void set_irp_result( struct irp_call *irp, unsigned int status,
|
|||
irp->file = NULL;
|
||||
if (irp->async)
|
||||
{
|
||||
void *out_data;
|
||||
|
||||
out_size = min( irp->iosb->out_size, out_size );
|
||||
if (out_size && !(out_data = memdup( out_data, out_size )))
|
||||
out_size = 0;
|
||||
async_request_complete( irp->async, status, result, out_size, out_data );
|
||||
async_request_complete_alloc( irp->async, status, result, out_size, out_data );
|
||||
release_object( irp->async );
|
||||
irp->async = NULL;
|
||||
}
|
||||
|
|
|
@ -229,6 +229,8 @@ extern int async_waiting( struct async_queue *queue );
|
|||
extern void async_terminate( struct async *async, unsigned int status );
|
||||
extern void async_request_complete( struct async *async, unsigned int status, data_size_t result,
|
||||
data_size_t out_size, void *out_data );
|
||||
extern void async_request_complete_alloc( struct async *async, unsigned int status, data_size_t result,
|
||||
data_size_t out_size, const void *out_data );
|
||||
extern void async_wake_up( struct async_queue *queue, unsigned int status );
|
||||
extern struct completion *fd_get_completion( struct fd *fd, apc_param_t *p_key );
|
||||
extern void fd_copy_completion( struct fd *src, struct fd *dst );
|
||||
|
|
|
@ -710,7 +710,6 @@ static void complete_async_accept( struct sock *sock, struct accept_req *req )
|
|||
else
|
||||
{
|
||||
obj_handle_t handle;
|
||||
void *out_data;
|
||||
|
||||
if (!(acceptsock = accept_socket( sock )))
|
||||
{
|
||||
|
@ -727,10 +726,7 @@ static void complete_async_accept( struct sock *sock, struct accept_req *req )
|
|||
return;
|
||||
}
|
||||
|
||||
if (!(out_data = malloc( sizeof(handle) ))) return;
|
||||
|
||||
memcpy( out_data, &handle, sizeof(handle) );
|
||||
async_request_complete( req->async, STATUS_SUCCESS, 0, sizeof(handle), out_data );
|
||||
async_request_complete_alloc( req->async, STATUS_SUCCESS, 0, sizeof(handle), &handle );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue