Jacek Caban : server: Use create_request_async for write requests.
Alexandre Julliard
julliard at winehq.org
Wed Jun 28 15:10:25 CDT 2017
Module: wine
Branch: master
Commit: 2bd828b13cf0307ca087d098e67f192dd236c1b0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2bd828b13cf0307ca087d098e67f192dd236c1b0
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Jun 26 12:18:23 2017 +0200
server: Use create_request_async for write requests.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/file.c | 6 +++++-
server/async.c | 3 ++-
server/device.c | 6 +++---
server/fd.c | 18 ++++++------------
server/file.h | 6 +++---
server/named_pipe.c | 26 ++++----------------------
6 files changed, 23 insertions(+), 42 deletions(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 3d9840f..b73af7e 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -624,6 +624,11 @@ static NTSTATUS server_write_file( HANDLE handle, HANDLE event, PIO_APC_ROUTINE
status = wine_server_call( req );
wait_handle = wine_server_ptr_handle( reply->wait );
options = reply->options;
+ if (wait_handle && status != STATUS_PENDING)
+ {
+ io->u.Status = status;
+ io->Information = reply->size;
+ }
}
SERVER_END_REQ;
@@ -633,7 +638,6 @@ static NTSTATUS server_write_file( HANDLE handle, HANDLE event, PIO_APC_ROUTINE
{
NtWaitForSingleObject( wait_handle, (options & FILE_SYNCHRONOUS_IO_ALERT), NULL );
status = io->u.Status;
- NtClose( wait_handle );
}
return status;
diff --git a/server/async.c b/server/async.c
index 7f2bcf5..b693c28 100644
--- a/server/async.c
+++ b/server/async.c
@@ -324,7 +324,7 @@ struct async *create_request_async( struct thread *thread, const async_data_t *d
}
/* return async object status and wait handle to client */
-obj_handle_t async_handoff( struct async *async, int success )
+obj_handle_t async_handoff( struct async *async, int success, data_size_t *result )
{
if (!success)
{
@@ -340,6 +340,7 @@ obj_handle_t async_handoff( struct async *async, int success )
set_reply_data_ptr( async->iosb->out_data, async->iosb->out_size );
async->iosb->out_data = NULL;
}
+ if (result) *result = async->iosb->result;
async->signaled = 1;
}
else
diff --git a/server/device.c b/server/device.c
index 4aa605b..4c7aa16 100644
--- a/server/device.c
+++ b/server/device.c
@@ -175,7 +175,7 @@ static int device_file_close_handle( struct object *obj, struct process *process
static void device_file_destroy( struct object *obj );
static enum server_fd_type device_file_get_fd_type( struct fd *fd );
static int device_file_read( struct fd *fd, struct async *async, file_pos_t pos );
-static obj_handle_t device_file_write( struct fd *fd, struct async *async, file_pos_t pos );
+static int device_file_write( struct fd *fd, struct async *async, file_pos_t pos );
static obj_handle_t device_file_flush( struct fd *fd, struct async *async );
static obj_handle_t device_file_ioctl( struct fd *fd, ioctl_code_t code, struct async *async );
@@ -506,7 +506,7 @@ static int device_file_read( struct fd *fd, struct async *async, file_pos_t pos
return handle;
}
-static obj_handle_t device_file_write( struct fd *fd, struct async *async, file_pos_t pos )
+static int device_file_write( struct fd *fd, struct async *async, file_pos_t pos )
{
struct device_file *file = get_fd_user( fd );
struct irp_call *irp;
@@ -522,7 +522,7 @@ static obj_handle_t device_file_write( struct fd *fd, struct async *async, file_
irp = create_irp( file, ¶ms, async );
if (!irp) return 0;
- handle = queue_irp( file, irp, async, 1 );
+ handle = queue_irp( file, irp, async, 0 );
release_object( irp );
return handle;
}
diff --git a/server/fd.c b/server/fd.c
index f6eb57d..0f1a15e 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -2165,7 +2165,7 @@ int no_fd_read( struct fd *fd, struct async *async, file_pos_t pos )
}
/* default write() routine */
-obj_handle_t no_fd_write( struct fd *fd, struct async *async, file_pos_t pos )
+int no_fd_write( struct fd *fd, struct async *async, file_pos_t pos )
{
set_error( STATUS_OBJECT_TYPE_MISMATCH );
return 0;
@@ -2451,7 +2451,7 @@ DECL_HANDLER(read)
if ((async = create_request_async( current, &req->async )))
{
- reply->wait = async_handoff( async, fd->fd_ops->read( fd, async, req->pos ) );
+ reply->wait = async_handoff( async, fd->fd_ops->read( fd, async, req->pos ), NULL );
reply->options = fd->options;
release_object( async );
}
@@ -2463,20 +2463,14 @@ 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 )))
+ if ((async = create_request_async( current, &req->async )))
{
- async = create_async( current, &req->async, iosb );
- if (async)
- {
- reply->wait = fd->fd_ops->write( fd, async, req->pos );
- reply->options = fd->options;
- release_object( async );
- }
- release_object( iosb );
+ reply->wait = async_handoff( async, fd->fd_ops->write( fd, async, req->pos ), &reply->size );
+ reply->options = fd->options;
+ release_object( async );
}
release_object( fd );
}
diff --git a/server/file.h b/server/file.h
index 8cc4d3b..96c1d23 100644
--- a/server/file.h
+++ b/server/file.h
@@ -54,7 +54,7 @@ struct fd_ops
/* perform a read on the file */
int (*read)(struct fd *, struct async *, file_pos_t );
/* perform a write on the file */
- obj_handle_t (*write)(struct fd *, struct async *, file_pos_t );
+ int (*write)(struct fd *, struct async *, file_pos_t );
/* flush the object buffers */
obj_handle_t (*flush)(struct fd *, struct async *);
/* perform an ioctl on the file */
@@ -101,7 +101,7 @@ 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 int no_fd_read( struct fd *fd, struct async *async, file_pos_t pos );
-extern obj_handle_t no_fd_write( struct fd *fd, struct async *async, file_pos_t pos );
+extern int no_fd_write( struct fd *fd, struct async *async, file_pos_t pos );
extern obj_handle_t no_fd_flush( struct fd *fd, struct async *async );
extern obj_handle_t no_fd_ioctl( struct fd *fd, ioctl_code_t code, struct async *async );
extern obj_handle_t default_fd_ioctl( struct fd *fd, ioctl_code_t code, struct async *async );
@@ -177,7 +177,7 @@ extern struct async_queue *create_async_queue( struct fd *fd );
extern void free_async_queue( struct async_queue *queue );
extern struct async *create_async( struct thread *thread, const async_data_t *data, struct iosb *iosb );
extern struct async *create_request_async( struct thread *thread, const async_data_t *data );
-extern obj_handle_t async_handoff( struct async *async, int success );
+extern obj_handle_t async_handoff( struct async *async, int success, data_size_t *result );
extern void queue_async( struct async_queue *queue, struct async *async );
extern void async_set_timeout( struct async *async, timeout_t timeout, unsigned int status );
extern void async_set_result( struct object *obj, unsigned int status, apc_param_t total );
diff --git a/server/named_pipe.c b/server/named_pipe.c
index 07ec006..f33daf8 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -155,7 +155,7 @@ static const struct object_ops named_pipe_ops =
/* common server and client pipe end functions */
static enum server_fd_type pipe_end_get_fd_type( struct fd *fd );
static int pipe_end_read( struct fd *fd, struct async *async, file_pos_t pos );
-static obj_handle_t pipe_end_write( struct fd *fd, struct async *async_data, file_pos_t pos );
+static int pipe_end_write( struct fd *fd, struct async *async_data, file_pos_t pos );
static void pipe_end_queue_async( struct fd *fd, struct async *async, int type, int count );
static void pipe_end_reselect_async( struct fd *fd, struct async_queue *queue );
@@ -830,12 +830,11 @@ static int pipe_end_read( struct fd *fd, struct async *async, file_pos_t pos )
return 1;
}
-static obj_handle_t pipe_end_write( struct fd *fd, struct async *async, file_pos_t pos )
+static int pipe_end_write( struct fd *fd, struct async *async, file_pos_t pos )
{
struct pipe_end *write_end = get_fd_user( fd );
struct pipe_end *read_end = write_end->connection;
struct pipe_message *message;
- obj_handle_t handle = 0;
if (!use_server_io( write_end )) return no_fd_write( fd, async, pos );
@@ -846,13 +845,8 @@ static obj_handle_t pipe_end_write( struct fd *fd, struct async *async, file_pos
}
if (!write_end->write_q && !(write_end->write_q = create_async_queue( fd ))) return 0;
- if (!(handle = alloc_handle( current->process, async, SYNCHRONIZE, 0 ))) return 0;
- if (!(message = mem_alloc( sizeof(*message) )))
- {
- close_handle( current->process, handle );
- return 0;
- }
+ if (!(message = mem_alloc( sizeof(*message) ))) return 0;
message->async = (struct async *)grab_object( async );
message->iosb = async_get_iosb( async );
message->read_pos = 0;
@@ -861,19 +855,7 @@ static obj_handle_t pipe_end_write( struct fd *fd, struct async *async, file_pos
queue_async( write_end->write_q, async );
reselect_write_queue( write_end );
set_error( STATUS_PENDING );
-
- if (!async_is_blocking( async ))
- {
- struct iosb *iosb;
- iosb = async_get_iosb( async );
- if (iosb->status == STATUS_PENDING)
- {
- close_handle( current->process, handle );
- handle = 0;
- }
- release_object( iosb );
- }
- return handle;
+ return 1;
}
static void pipe_end_queue_async( struct fd *fd, struct async *async, int type, int count )
More information about the wine-cvs
mailing list