server: Create async object in register_async handler.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Jacek Caban 2017-02-15 22:12:45 +01:00 committed by Alexandre Julliard
parent 8ef4f9a0c8
commit a604db1261
5 changed files with 20 additions and 23 deletions

View File

@ -2091,16 +2091,14 @@ void fd_reselect_async( struct fd *fd, struct async_queue *queue )
fd->fd_ops->reselect_async( fd, queue );
}
void no_fd_queue_async( struct fd *fd, const async_data_t *data, int type, int count )
void no_fd_queue_async( struct fd *fd, struct async *async, int type, int count )
{
set_error( STATUS_OBJECT_TYPE_MISMATCH );
}
void default_fd_queue_async( struct fd *fd, const async_data_t *data, int type, int count )
void default_fd_queue_async( struct fd *fd, struct async *async, int type, int count )
{
struct async *async;
if ((async = fd_queue_async( fd, data, NULL, type )))
if ((async = fd_queue_async( fd, async_get_data( async ), NULL, type )))
{
release_object( async );
set_error( STATUS_PENDING );
@ -2509,6 +2507,7 @@ DECL_HANDLER(ioctl)
DECL_HANDLER(register_async)
{
unsigned int access;
struct async *async;
struct fd *fd;
switch(req->type)
@ -2526,7 +2525,11 @@ DECL_HANDLER(register_async)
if ((fd = get_handle_fd_obj( current->process, req->async.handle, access )))
{
if (get_unix_fd( fd ) != -1) fd->fd_ops->queue_async( fd, &req->async, req->type, req->count );
if (get_unix_fd( fd ) != -1 && (async = create_async( current, &req->async, NULL )))
{
fd->fd_ops->queue_async( fd, async, req->type, req->count );
release_object( async );
}
release_object( fd );
}
}

View File

@ -60,7 +60,7 @@ struct fd_ops
/* perform an ioctl on the file */
obj_handle_t (*ioctl)(struct fd *fd, ioctl_code_t code, const async_data_t *async, int blocking );
/* queue an async operation */
void (*queue_async)(struct fd *, const async_data_t *data, int type, int count);
void (*queue_async)(struct fd *, struct async *async, int type, int count);
/* selected events for async i/o need an update */
void (*reselect_async)( struct fd *, struct async_queue *queue );
};
@ -105,8 +105,8 @@ extern obj_handle_t no_fd_write( struct fd *fd, struct async *async, int blockin
extern obj_handle_t no_fd_flush( struct fd *fd, const async_data_t *async, int blocking );
extern obj_handle_t no_fd_ioctl( struct fd *fd, ioctl_code_t code, const async_data_t *async, int blocking );
extern obj_handle_t default_fd_ioctl( struct fd *fd, ioctl_code_t code, const async_data_t *async, int blocking );
extern void no_fd_queue_async( struct fd *fd, const async_data_t *data, int type, int count );
extern void default_fd_queue_async( struct fd *fd, const async_data_t *data, int type, int count );
extern void no_fd_queue_async( struct fd *fd, struct async *async, int type, int count );
extern void default_fd_queue_async( struct fd *fd, struct async *async, int type, int count );
extern void default_fd_reselect_async( struct fd *fd, struct async_queue *queue );
extern void main_loop(void);
extern void remove_process_locks( struct process *process );

View File

@ -94,7 +94,7 @@ static const struct object_ops mailslot_ops =
};
static enum server_fd_type mailslot_get_fd_type( struct fd *fd );
static void mailslot_queue_async( struct fd *fd, const async_data_t *data, int type, int count );
static void mailslot_queue_async( struct fd *fd, struct async *async, int type, int count );
static const struct fd_ops mailslot_fd_ops =
{
@ -325,14 +325,13 @@ static struct object *mailslot_open_file( struct object *obj, unsigned int acces
return &writer->obj;
}
static void mailslot_queue_async( struct fd *fd, const async_data_t *data, int type, int count )
static void mailslot_queue_async( struct fd *fd, struct async *async, int type, int count )
{
struct mailslot *mailslot = get_fd_user( fd );
struct async *async;
assert(mailslot->obj.ops == &mailslot_ops);
if ((async = fd_queue_async( fd, data, NULL, type )))
if ((async = fd_queue_async( fd, async_get_data( async ), NULL, type )))
{
async_set_timeout( async, mailslot->read_timeout ? mailslot->read_timeout : -1,
STATUS_IO_TIMEOUT );

View File

@ -61,7 +61,7 @@ static struct fd *serial_get_fd( struct object *obj );
static void serial_destroy(struct object *obj);
static enum server_fd_type serial_get_fd_type( struct fd *fd );
static void serial_queue_async( struct fd *fd, const async_data_t *data, int type, int count );
static void serial_queue_async( struct fd *fd, struct async *async, int type, int count );
static void serial_reselect_async( struct fd *fd, struct async_queue *queue );
struct serial
@ -183,11 +183,10 @@ static enum server_fd_type serial_get_fd_type( struct fd *fd )
return FD_TYPE_SERIAL;
}
static void serial_queue_async( struct fd *fd, const async_data_t *data, int type, int count )
static void serial_queue_async( struct fd *fd, struct async *async, int type, int count )
{
struct serial *serial = get_fd_user( fd );
timeout_t timeout = 0;
struct async *async;
assert(serial->obj.ops == &serial_ops);
@ -201,7 +200,7 @@ static void serial_queue_async( struct fd *fd, const async_data_t *data, int typ
break;
}
if ((async = fd_queue_async( fd, data, NULL, type )))
if ((async = fd_queue_async( fd, async_get_data( async ), NULL, type )))
{
if (timeout) async_set_timeout( async, timeout * -10000, STATUS_TIMEOUT );
release_object( async );

View File

@ -130,7 +130,7 @@ static int sock_get_poll_events( struct fd *fd );
static void sock_poll_event( struct fd *fd, int event );
static enum server_fd_type sock_get_fd_type( struct fd *fd );
static obj_handle_t sock_ioctl( struct fd *fd, ioctl_code_t code, const async_data_t *async, int blocking );
static void sock_queue_async( struct fd *fd, const async_data_t *data, int type, int count );
static void sock_queue_async( struct fd *fd, struct async *async, int type, int count );
static void sock_reselect_async( struct fd *fd, struct async_queue *queue );
static int sock_get_ntstatus( int err );
@ -564,10 +564,9 @@ obj_handle_t sock_ioctl( struct fd *fd, ioctl_code_t code, const async_data_t *a
}
}
static void sock_queue_async( struct fd *fd, const async_data_t *data, int type, int count )
static void sock_queue_async( struct fd *fd, struct async *async, int type, int count )
{
struct sock *sock = get_fd_user( fd );
struct async *async;
struct async_queue *queue;
assert( sock->obj.ops == &sock_ops );
@ -594,10 +593,7 @@ static void sock_queue_async( struct fd *fd, const async_data_t *data, int type,
return;
}
if (!(async = create_async( current, data, NULL ))) return;
queue_async( queue, async );
release_object( async );
sock_reselect( sock );
set_error( STATUS_PENDING );