Jacek Caban : server: Create async objects in read and write request handlers.

Alexandre Julliard julliard at winehq.org
Tue Feb 21 16:56:13 CST 2017


Module: wine
Branch: master
Commit: 8ef4f9a0c8acffcde2cc21eb81ff8010ddddd363
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=8ef4f9a0c8acffcde2cc21eb81ff8010ddddd363

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Feb 15 22:12:37 2017 +0100

server: Create async objects in read and write request handlers.

async_get_data allows splitting patches, but will be removed later in
the series.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 server/async.c  | 10 ++++++++++
 server/device.c | 22 ++++++++++++----------
 server/fd.c     | 25 ++++++++++++++++++-------
 server/file.h   | 12 ++++++------
 4 files changed, 46 insertions(+), 23 deletions(-)

diff --git a/server/async.c b/server/async.c
index 3de60b6..aa50333 100644
--- a/server/async.c
+++ b/server/async.c
@@ -469,6 +469,16 @@ struct iosb *create_iosb( const void *in_data, data_size_t in_size, data_size_t
     return iosb;
 }
 
+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/device.c b/server/device.c
index bece6a8..90ebc9e 100644
--- a/server/device.c
+++ b/server/device.c
@@ -174,10 +174,8 @@ static struct fd *device_file_get_fd( struct object *obj );
 static int device_file_close_handle( struct object *obj, struct process *process, obj_handle_t handle );
 static void device_file_destroy( struct object *obj );
 static enum server_fd_type device_file_get_fd_type( struct fd *fd );
-static obj_handle_t device_file_read( struct fd *fd, const async_data_t *async_data, int blocking,
-                                      file_pos_t pos, struct iosb *iosb );
-static obj_handle_t device_file_write( struct fd *fd, const async_data_t *async_data, int blocking,
-                                       file_pos_t pos, struct iosb *iosb );
+static obj_handle_t device_file_read( struct fd *fd, struct async *async, int blocking, file_pos_t pos );
+static obj_handle_t device_file_write( struct fd *fd, struct async *async, int blocking, file_pos_t pos );
 static obj_handle_t device_file_flush( struct fd *fd, const async_data_t *async_data, int blocking );
 static obj_handle_t device_file_ioctl( struct fd *fd, ioctl_code_t code, const async_data_t *async_data,
                                        int blocking );
@@ -489,13 +487,13 @@ static enum server_fd_type device_file_get_fd_type( struct fd *fd )
     return FD_TYPE_DEVICE;
 }
 
-static obj_handle_t device_file_read( struct fd *fd, const async_data_t *async_data, int blocking,
-                                      file_pos_t pos, struct iosb *iosb )
+static obj_handle_t device_file_read( struct fd *fd, struct async *async, int blocking, file_pos_t pos )
 {
     struct device_file *file = get_fd_user( fd );
     struct irp_call *irp;
     obj_handle_t handle;
     irp_params_t params;
+    struct iosb *iosb;
 
     memset( &params, 0, sizeof(params) );
     params.read.major = IRP_MJ_READ;
@@ -503,21 +501,23 @@ static obj_handle_t device_file_read( struct fd *fd, const async_data_t *async_d
     params.read.pos   = pos;
     params.read.file  = file->user_ptr;
 
+    iosb = async_get_iosb( async );
     irp = create_irp( file, &params, iosb );
+    release_object( iosb );
     if (!irp) return 0;
 
-    handle = queue_irp( file, irp, async_data, blocking );
+    handle = queue_irp( file, irp, async_get_data( async ), blocking );
     release_object( irp );
     return handle;
 }
 
-static obj_handle_t device_file_write( struct fd *fd, const async_data_t *async_data, int blocking,
-                                       file_pos_t pos, struct iosb *iosb )
+static obj_handle_t device_file_write( struct fd *fd, struct async *async, int blocking, file_pos_t pos )
 {
     struct device_file *file = get_fd_user( fd );
     struct irp_call *irp;
     obj_handle_t handle;
     irp_params_t params;
+    struct iosb *iosb;
 
     memset( &params, 0, sizeof(params) );
     params.write.major = IRP_MJ_WRITE;
@@ -525,10 +525,12 @@ static obj_handle_t device_file_write( struct fd *fd, const async_data_t *async_
     params.write.pos   = pos;
     params.write.file  = file->user_ptr;
 
+    iosb = async_get_iosb( async );
     irp = create_irp( file, &params, iosb );
+    release_object( iosb );
     if (!irp) return 0;
 
-    handle = queue_irp( file, irp, async_data, blocking );
+    handle = queue_irp( file, irp, async_get_data( async ), blocking );
     release_object( irp );
     return handle;
 }
diff --git a/server/fd.c b/server/fd.c
index 31d0f4a..202bd56 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -2167,15 +2167,14 @@ static void unmount_device( struct fd *device_fd )
 }
 
 /* default read() routine */
-obj_handle_t no_fd_read( struct fd *fd, const async_data_t *async, int blocking, file_pos_t pos, struct iosb *iosb )
+obj_handle_t no_fd_read( struct fd *fd, struct async *async, int blocking, file_pos_t pos )
 {
     set_error( STATUS_OBJECT_TYPE_MISMATCH );
     return 0;
 }
 
 /* default write() routine */
-obj_handle_t no_fd_write( struct fd *fd, const async_data_t *async, int blocking,
-                          file_pos_t pos, struct iosb *iosb )
+obj_handle_t no_fd_write( struct fd *fd, struct async *async, int blocking, file_pos_t pos )
 {
     set_error( STATUS_OBJECT_TYPE_MISMATCH );
     return 0;
@@ -2450,14 +2449,20 @@ DECL_HANDLER(get_handle_fd)
 DECL_HANDLER(read)
 {
     struct fd *fd = get_handle_fd_obj( current->process, req->async.handle, FILE_READ_DATA );
+    struct async *async;
     struct iosb *iosb;
 
     if (!fd) return;
 
     if ((iosb = create_iosb( NULL, 0, get_reply_max_size() )))
     {
-        reply->wait    = fd->fd_ops->read( fd, &req->async, req->blocking, req->pos, iosb );
-        reply->options = fd->options;
+        async = create_async( current, &req->async, iosb );
+        if (async)
+        {
+            reply->wait    = fd->fd_ops->read( fd, async, req->blocking, req->pos );
+            reply->options = fd->options;
+            release_object( async );
+        }
         release_object( iosb );
     }
     release_object( fd );
@@ -2467,14 +2472,20 @@ DECL_HANDLER(read)
 DECL_HANDLER(write)
 {
     struct fd *fd = get_handle_fd_obj( current->process, req->async.handle, FILE_WRITE_DATA );
+    struct async *async;
     struct iosb *iosb;
 
     if (!fd) return;
 
     if ((iosb = create_iosb( get_req_data(), get_req_data_size(), 0 )))
     {
-        reply->wait    = fd->fd_ops->write( fd, &req->async, req->blocking, req->pos, iosb );
-        reply->options = fd->options;
+        async = create_async( current, &req->async, iosb );
+        if (async)
+        {
+            reply->wait    = fd->fd_ops->write( fd, async, req->blocking, req->pos );
+            reply->options = fd->options;
+            release_object( async );
+        }
         release_object( iosb );
     }
     release_object( fd );
diff --git a/server/file.h b/server/file.h
index af497da..3605053 100644
--- a/server/file.h
+++ b/server/file.h
@@ -52,9 +52,9 @@ struct fd_ops
     /* get file information */
     enum server_fd_type (*get_fd_type)(struct fd *fd);
     /* perform a read on the file */
-    obj_handle_t (*read)(struct fd *, const async_data_t *, int, file_pos_t, struct iosb * );
+    obj_handle_t (*read)(struct fd *, struct async *, int, file_pos_t );
     /* perform a write on the file */
-    obj_handle_t (*write)(struct fd *, const async_data_t *, int, file_pos_t, struct iosb * );
+    obj_handle_t (*write)(struct fd *, struct async *, int, file_pos_t );
     /* flush the object buffers */
     obj_handle_t (*flush)(struct fd *, const async_data_t *, int);
     /* perform an ioctl on the file */
@@ -100,10 +100,8 @@ 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 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, const async_data_t *async, int blocking, file_pos_t pos,
-                                struct iosb *iosb );
-extern obj_handle_t no_fd_write( struct fd *fd, const async_data_t *async, int blocking,
-                                 file_pos_t pos, struct iosb *iosb );
+extern obj_handle_t no_fd_read( struct fd *fd, struct async *async, int blocking, file_pos_t pos );
+extern obj_handle_t no_fd_write( struct fd *fd, struct async *async, int blocking, file_pos_t pos );
 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 );
@@ -189,6 +187,8 @@ 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 );
 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 */




More information about the wine-cvs mailing list