diff --git a/server/async.c b/server/async.c index aa50333acc7..4e30c2e6f85 100644 --- a/server/async.c +++ b/server/async.c @@ -474,11 +474,6 @@ struct iosb *async_get_iosb( struct async *async ) return async->iosb ? (struct iosb *)grab_object( async->iosb ) : NULL; } -const async_data_t *async_get_data( struct async *async ) -{ - return &async->data; -} - /* cancels all async I/O */ DECL_HANDLER(cancel_async) { diff --git a/server/change.c b/server/change.c index d7ebf3bf3ac..14fb2f1e762 100644 --- a/server/change.c +++ b/server/change.c @@ -1246,7 +1246,8 @@ DECL_HANDLER(read_directory_changes) return; /* requests don't timeout */ - if (!(async = fd_queue_async( dir->fd, &req->async, NULL, ASYNC_TYPE_WAIT ))) goto end; + if (!(async = create_async( current, &req->async, NULL ))) goto end; + if (!fd_queue_async( dir->fd, async, ASYNC_TYPE_WAIT )) goto end; /* assign it once */ if (!dir->filter) @@ -1266,10 +1267,10 @@ DECL_HANDLER(read_directory_changes) if (!inotify_adjust_changes( dir )) dnotify_adjust_changes( dir ); - release_object( async ); set_error(STATUS_PENDING); end: + if (async) release_object( async ); release_object( dir ); } diff --git a/server/device.c b/server/device.c index d5574ae325f..8c46a69fc65 100644 --- a/server/device.c +++ b/server/device.c @@ -242,7 +242,7 @@ static void irp_call_destroy( struct object *obj ) if (irp->thread) release_object( irp->thread ); } -static struct irp_call *create_irp( struct device_file *file, const irp_params_t *params, struct iosb *iosb ) +static struct irp_call *create_irp( struct device_file *file, const irp_params_t *params, struct async *async ) { struct irp_call *irp; @@ -258,12 +258,10 @@ static struct irp_call *create_irp( struct device_file *file, const irp_params_t irp->thread = NULL; irp->async = NULL; irp->params = *params; + irp->iosb = NULL; - if (iosb) - { - irp->iosb = (struct iosb *)grab_object( iosb ); - } - else if (!(irp->iosb = create_iosb( NULL, 0, 0 ))) + if (async) irp->iosb = async_get_iosb( async ); + if (!irp->iosb && !(irp->iosb = create_iosb( NULL, 0, 0 ))) { release_object( irp ); irp = NULL; @@ -471,11 +469,12 @@ static obj_handle_t queue_irp( struct device_file *file, struct irp_call *irp, if (blocking && !(handle = alloc_handle( current->process, irp, SYNCHRONIZE, 0 ))) return 0; - if (!(irp->async = fd_queue_async( file->fd, async_get_data( async ), irp->iosb, ASYNC_TYPE_WAIT ))) + if (!fd_queue_async( file->fd, async, ASYNC_TYPE_WAIT )) { if (handle) close_handle( current->process, handle ); return 0; } + irp->async = (struct async *)grab_object( async ); add_irp_to_queue( file, irp, current ); set_error( STATUS_PENDING ); return handle; @@ -492,7 +491,6 @@ static obj_handle_t device_file_read( struct fd *fd, struct async *async, int bl struct irp_call *irp; obj_handle_t handle; irp_params_t params; - struct iosb *iosb; memset( ¶ms, 0, sizeof(params) ); params.read.major = IRP_MJ_READ; @@ -500,9 +498,7 @@ static obj_handle_t device_file_read( struct fd *fd, struct async *async, int bl params.read.pos = pos; params.read.file = file->user_ptr; - iosb = async_get_iosb( async ); - irp = create_irp( file, ¶ms, iosb ); - release_object( iosb ); + irp = create_irp( file, ¶ms, async ); if (!irp) return 0; handle = queue_irp( file, irp, async, blocking ); @@ -516,7 +512,6 @@ static obj_handle_t device_file_write( struct fd *fd, struct async *async, int b struct irp_call *irp; obj_handle_t handle; irp_params_t params; - struct iosb *iosb; memset( ¶ms, 0, sizeof(params) ); params.write.major = IRP_MJ_WRITE; @@ -524,9 +519,7 @@ static obj_handle_t device_file_write( struct fd *fd, struct async *async, int b params.write.pos = pos; params.write.file = file->user_ptr; - iosb = async_get_iosb( async ); - irp = create_irp( file, ¶ms, iosb ); - release_object( iosb ); + irp = create_irp( file, ¶ms, async ); if (!irp) return 0; handle = queue_irp( file, irp, async, blocking ); @@ -560,17 +553,13 @@ static obj_handle_t device_file_ioctl( struct fd *fd, ioctl_code_t code, struct struct irp_call *irp; obj_handle_t handle; irp_params_t params; - struct iosb *iosb; memset( ¶ms, 0, sizeof(params) ); params.ioctl.major = IRP_MJ_DEVICE_CONTROL; params.ioctl.code = code; params.ioctl.file = file->user_ptr; - iosb = create_iosb( get_req_data(), get_req_data_size(), get_reply_max_size() ); - if (!iosb) return 0; - irp = create_irp( file, ¶ms, iosb ); - release_object(iosb); + irp = create_irp( file, ¶ms, async ); if (!irp) return 0; handle = queue_irp( file, irp, async, blocking ); diff --git a/server/fd.c b/server/fd.c index 2ed639f2d3e..bcb1badad16 100644 --- a/server/fd.c +++ b/server/fd.c @@ -2030,23 +2030,22 @@ void default_poll_event( struct fd *fd, int event ) else if (!fd->inode) set_fd_events( fd, fd->fd_ops->get_poll_events( fd ) ); } -struct async *fd_queue_async( struct fd *fd, const async_data_t *data, struct iosb *iosb, int type ) +int fd_queue_async( struct fd *fd, struct async *async, int type ) { struct async_queue *queue; - struct async *async; switch (type) { case ASYNC_TYPE_READ: - if (!fd->read_q && !(fd->read_q = create_async_queue( fd ))) return NULL; + if (!fd->read_q && !(fd->read_q = create_async_queue( fd ))) return 0; queue = fd->read_q; break; case ASYNC_TYPE_WRITE: - if (!fd->write_q && !(fd->write_q = create_async_queue( fd ))) return NULL; + if (!fd->write_q && !(fd->write_q = create_async_queue( fd ))) return 0; queue = fd->write_q; break; case ASYNC_TYPE_WAIT: - if (!fd->wait_q && !(fd->wait_q = create_async_queue( fd ))) return NULL; + if (!fd->wait_q && !(fd->wait_q = create_async_queue( fd ))) return 0; queue = fd->wait_q; break; default: @@ -2054,18 +2053,16 @@ struct async *fd_queue_async( struct fd *fd, const async_data_t *data, struct io assert(0); } - if ((async = create_async( current, data, iosb ))) + queue_async( queue, async ); + + if (type != ASYNC_TYPE_WAIT) { - queue_async( queue, async ); - if (type != ASYNC_TYPE_WAIT) - { - if (!fd->inode) - set_fd_events( fd, fd->fd_ops->get_poll_events( fd ) ); - else /* regular files are always ready for read and write */ - async_wake_up( queue, STATUS_ALERTED ); - } + if (!fd->inode) + set_fd_events( fd, fd->fd_ops->get_poll_events( fd ) ); + else /* regular files are always ready for read and write */ + async_wake_up( queue, STATUS_ALERTED ); } - return async; + return 1; } void fd_async_wake_up( struct fd *fd, int type, unsigned int status ) @@ -2098,11 +2095,7 @@ void no_fd_queue_async( struct fd *fd, struct async *async, int type, int count void default_fd_queue_async( struct fd *fd, struct async *async, int type, int count ) { - if ((async = fd_queue_async( fd, async_get_data( async ), NULL, type ))) - { - release_object( async ); - set_error( STATUS_PENDING ); - } + if (fd_queue_async( fd, async, type )) set_error( STATUS_PENDING ); } /* default reselect_async() fd routine */ diff --git a/server/file.h b/server/file.h index 0a0e72f1e84..8e906d3ebf8 100644 --- a/server/file.h +++ b/server/file.h @@ -97,7 +97,7 @@ extern int default_fd_signaled( struct object *obj, struct wait_queue_entry *ent extern unsigned int default_fd_map_access( struct object *obj, unsigned int access ); extern int default_fd_get_poll_events( struct fd *fd ); extern void default_poll_event( struct fd *fd, int event ); -extern struct async *fd_queue_async( struct fd *fd, const async_data_t *data, struct iosb *iosb, int type ); +extern int fd_queue_async( struct fd *fd, struct async *async, int type ); extern void fd_async_wake_up( struct fd *fd, int type, unsigned int status ); extern void fd_reselect_async( struct fd *fd, struct async_queue *queue ); extern obj_handle_t no_fd_read( struct fd *fd, struct async *async, int blocking, file_pos_t pos ); @@ -188,7 +188,6 @@ 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 ); extern struct iosb *create_iosb( const void *in_data, data_size_t in_size, data_size_t out_size ); extern struct iosb *async_get_iosb( struct async *async ); -extern const async_data_t *async_get_data( struct async *async ); extern void cancel_process_asyncs( struct process *process ); /* access rights that require Unix read permission */ diff --git a/server/mailslot.c b/server/mailslot.c index 20bf99cc5b0..643577cd72c 100644 --- a/server/mailslot.c +++ b/server/mailslot.c @@ -331,11 +331,10 @@ static void mailslot_queue_async( struct fd *fd, struct async *async, int type, assert(mailslot->obj.ops == &mailslot_ops); - if ((async = fd_queue_async( fd, async_get_data( async ), NULL, type ))) + if (fd_queue_async( fd, async, type )) { async_set_timeout( async, mailslot->read_timeout ? mailslot->read_timeout : -1, STATUS_IO_TIMEOUT ); - release_object( async ); set_error( STATUS_PENDING ); } } diff --git a/server/named_pipe.c b/server/named_pipe.c index 1426023ad68..50e6389ec51 100644 --- a/server/named_pipe.c +++ b/server/named_pipe.c @@ -554,13 +554,12 @@ static obj_handle_t pipe_server_flush( struct fd *fd, struct async *async, int b if (!pipe_data_remaining( server )) return 0; - if ((async = fd_queue_async( server->fd, async_get_data( async ), NULL, ASYNC_TYPE_WAIT ))) + if (fd_queue_async( server->fd, async, ASYNC_TYPE_WAIT )) { /* there's no unix way to be alerted when a pipe becomes empty, so resort to polling */ if (!server->flush_poll) server->flush_poll = add_timeout_user( -TICKS_PER_SEC / 10, check_flushed, server ); if (blocking) handle = alloc_handle( current->process, async, SYNCHRONIZE, 0 ); - release_object( async ); set_error( STATUS_PENDING ); } return handle; @@ -600,12 +599,11 @@ static obj_handle_t pipe_server_ioctl( struct fd *fd, ioctl_code_t code, struct { case ps_idle_server: case ps_wait_connect: - if ((async = fd_queue_async( server->ioctl_fd, async_get_data( async ), NULL, ASYNC_TYPE_WAIT ))) + if (fd_queue_async( server->ioctl_fd, async, ASYNC_TYPE_WAIT )) { if (blocking) wait_handle = alloc_handle( current->process, async, SYNCHRONIZE, 0 ); set_server_state( server, ps_wait_open ); if (server->pipe->waiters) async_wake_up( server->pipe->waiters, STATUS_SUCCESS ); - release_object( async ); set_error( STATUS_PENDING ); return wait_handle; } diff --git a/server/serial.c b/server/serial.c index 58170cd1134..fea3c8c9506 100644 --- a/server/serial.c +++ b/server/serial.c @@ -200,10 +200,9 @@ static void serial_queue_async( struct fd *fd, struct async *async, int type, in break; } - if ((async = fd_queue_async( fd, async_get_data( async ), NULL, type ))) + if (fd_queue_async( fd, async, type )) { if (timeout) async_set_timeout( async, timeout * -10000, STATUS_TIMEOUT ); - release_object( async ); set_error( STATUS_PENDING ); } }