From f6fa72d77067aa8f39675d74600ffb57caf8327e Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 15 Dec 2008 13:30:25 +0100 Subject: [PATCH] server: Make async I/O transfer sizes always 32-bit. --- dlls/ntdll/directory.c | 2 +- dlls/ntdll/file.c | 8 ++++---- dlls/ntdll/ntdll_misc.h | 3 ++- dlls/ntdll/sync.c | 3 ++- dlls/ws2_32/socket.c | 10 ++++++---- include/wine/server_protocol.h | 10 +++++----- server/async.c | 2 +- server/completion.c | 4 ++-- server/file.h | 4 ++-- server/protocol.def | 10 +++++----- server/trace.c | 6 +++--- tools/make_requests | 1 - 12 files changed, 33 insertions(+), 30 deletions(-) diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c index 74699490193..baff45aa906 100644 --- a/dlls/ntdll/directory.c +++ b/dlls/ntdll/directory.c @@ -2302,7 +2302,7 @@ static void WINAPI read_changes_user_apc( void *arg, IO_STATUS_BLOCK *io, ULONG RtlFreeHeap( GetProcessHeap(), 0, info ); } -static NTSTATUS read_changes_apc( void *user, PIO_STATUS_BLOCK iosb, NTSTATUS status, ULONG_PTR *total ) +static NTSTATUS read_changes_apc( void *user, PIO_STATUS_BLOCK iosb, NTSTATUS status, ULONG *total ) { struct read_changes_info *info = user; char path[PATH_MAX]; diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c index 50ee3f77c52..9d6ed673c5d 100644 --- a/dlls/ntdll/file.c +++ b/dlls/ntdll/file.c @@ -334,7 +334,7 @@ NTSTATUS FILE_GetNtStatus(void) /*********************************************************************** * FILE_AsyncReadService (INTERNAL) */ -static NTSTATUS FILE_AsyncReadService(void *user, PIO_STATUS_BLOCK iosb, NTSTATUS status, ULONG_PTR *total) +static NTSTATUS FILE_AsyncReadService(void *user, PIO_STATUS_BLOCK iosb, NTSTATUS status, ULONG *total) { async_fileio_read *fileio = user; int fd, needs_close, result; @@ -812,7 +812,7 @@ NTSTATUS WINAPI NtReadFileScatter( HANDLE file, HANDLE event, PIO_APC_ROUTINE ap /*********************************************************************** * FILE_AsyncWriteService (INTERNAL) */ -static NTSTATUS FILE_AsyncWriteService(void *user, IO_STATUS_BLOCK *iosb, NTSTATUS status, ULONG_PTR *total) +static NTSTATUS FILE_AsyncWriteService(void *user, IO_STATUS_BLOCK *iosb, NTSTATUS status, ULONG *total) { async_fileio_write *fileio = user; int result, fd, needs_close; @@ -1146,7 +1146,7 @@ struct async_ioctl }; /* callback for ioctl async I/O completion */ -static NTSTATUS ioctl_completion( void *arg, IO_STATUS_BLOCK *io, NTSTATUS status ) +static NTSTATUS ioctl_completion( void *arg, IO_STATUS_BLOCK *io, NTSTATUS status, ULONG *total ) { struct async_ioctl *async = arg; @@ -1158,7 +1158,7 @@ static NTSTATUS ioctl_completion( void *arg, IO_STATUS_BLOCK *io, NTSTATUS statu req->user_arg = async; wine_server_set_reply( req, async->buffer, async->size ); if (!(status = wine_server_call( req ))) - io->Information = wine_server_reply_size( reply ); + io->Information = *total = wine_server_reply_size( reply ); } SERVER_END_REQ; } diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index 63e121e8fd8..4474f2f9d01 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -211,6 +211,7 @@ static inline struct ntdll_thread_regs *ntdll_get_thread_regs(void) } /* Completion */ -extern NTSTATUS NTDLL_AddCompletion( HANDLE hFile, ULONG_PTR CompletionValue, NTSTATUS CompletionStatus, ULONG_PTR Information ); +extern NTSTATUS NTDLL_AddCompletion( HANDLE hFile, ULONG_PTR CompletionValue, + NTSTATUS CompletionStatus, ULONG Information ); #endif diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c index bad6eabf403..a2e36c4e1b5 100644 --- a/dlls/ntdll/sync.c +++ b/dlls/ntdll/sync.c @@ -1393,7 +1393,8 @@ NTSTATUS WINAPI NtQueryIoCompletion( HANDLE CompletionPort, IO_COMPLETION_INFORM return status; } -NTSTATUS NTDLL_AddCompletion( HANDLE hFile, ULONG_PTR CompletionValue, NTSTATUS CompletionStatus, ULONG_PTR Information ) +NTSTATUS NTDLL_AddCompletion( HANDLE hFile, ULONG_PTR CompletionValue, + NTSTATUS CompletionStatus, ULONG Information ) { NTSTATUS status; diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index b05067af428..14f357fc1b5 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -1124,7 +1124,7 @@ static int WS2_recv( int fd, struct ws2_async *wsa ) * * Handler for overlapped recv() operations. */ -static NTSTATUS WS2_async_recv( void* user, IO_STATUS_BLOCK* iosb, NTSTATUS status, ULONG_PTR *total ) +static NTSTATUS WS2_async_recv( void* user, IO_STATUS_BLOCK* iosb, NTSTATUS status, ULONG *total ) { ws2_async* wsa = user; int result = 0, fd; @@ -1225,7 +1225,7 @@ static int WS2_send( int fd, struct ws2_async *wsa ) * * Handler for overlapped send() operations. */ -static NTSTATUS WS2_async_send(void* user, IO_STATUS_BLOCK* iosb, NTSTATUS status, ULONG_PTR *total ) +static NTSTATUS WS2_async_send(void* user, IO_STATUS_BLOCK* iosb, NTSTATUS status, ULONG *total ) { ws2_async* wsa = user; int result = 0, fd; @@ -1280,7 +1280,7 @@ static NTSTATUS WS2_async_send(void* user, IO_STATUS_BLOCK* iosb, NTSTATUS statu * * Handler for shutdown() operations on overlapped sockets. */ -static NTSTATUS WS2_async_shutdown( void* user, PIO_STATUS_BLOCK iosb, NTSTATUS status ) +static NTSTATUS WS2_async_shutdown( void* user, PIO_STATUS_BLOCK iosb, NTSTATUS status, ULONG *total ) { ws2_async* wsa = user; int fd, err = 1; @@ -1300,6 +1300,7 @@ static NTSTATUS WS2_async_shutdown( void* user, PIO_STATUS_BLOCK iosb, NTSTATUS status = err ? wsaErrno() : STATUS_SUCCESS; break; } + *total = 0; iosb->u.Status = status; return status; } @@ -2647,7 +2648,8 @@ int WINAPI WS_select(int nfds, WS_fd_set *ws_readfds, } /* helper to send completion messages for client-only i/o operation case */ -static void WS_AddCompletion( SOCKET sock, ULONG_PTR CompletionValue, NTSTATUS CompletionStatus, ULONG_PTR Information ) +static void WS_AddCompletion( SOCKET sock, ULONG_PTR CompletionValue, NTSTATUS CompletionStatus, + ULONG Information ) { NTSTATUS status; diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index f69e7970d9b..129ca7ac01e 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -273,7 +273,7 @@ typedef union struct { enum apc_type type; - unsigned int (*func)(void*, void*, unsigned int, unsigned long *); + unsigned int (*func)(void*, void*, unsigned int, unsigned int *); void *user; void *sb; unsigned int status; @@ -358,7 +358,7 @@ typedef union { enum apc_type type; unsigned int status; - unsigned long total; + unsigned int total; } async_io; struct { @@ -4227,7 +4227,7 @@ struct add_completion_request obj_handle_t handle; apc_param_t ckey; apc_param_t cvalue; - unsigned long information; + unsigned int information; unsigned int status; }; struct add_completion_reply @@ -4247,7 +4247,7 @@ struct remove_completion_reply struct reply_header __header; apc_param_t ckey; apc_param_t cvalue; - unsigned long information; + unsigned int information; unsigned int status; }; @@ -4286,7 +4286,7 @@ struct add_fd_completion_request obj_handle_t handle; apc_param_t cvalue; unsigned int status; - unsigned long information; + unsigned int information; }; struct add_fd_completion_reply { diff --git a/server/async.c b/server/async.c index 4466de2d91e..6dea6bc0176 100644 --- a/server/async.c +++ b/server/async.c @@ -234,7 +234,7 @@ void async_set_timeout( struct async *async, timeout_t timeout, unsigned int sta } /* store the result of the client-side async callback */ -void async_set_result( struct object *obj, unsigned int status, unsigned long total ) +void async_set_result( struct object *obj, unsigned int status, unsigned int total ) { struct async *async = (struct async *)obj; diff --git a/server/completion.c b/server/completion.c index f9b8901e5e1..2a8f9ac2cc1 100644 --- a/server/completion.c +++ b/server/completion.c @@ -81,7 +81,7 @@ struct comp_msg struct list queue_entry; apc_param_t ckey; apc_param_t cvalue; - unsigned long information; + unsigned int information; unsigned int status; }; @@ -142,7 +142,7 @@ struct completion *get_completion_obj( struct process *process, obj_handle_t han } void add_completion( struct completion *completion, apc_param_t ckey, apc_param_t cvalue, - unsigned int status, unsigned long information ) + unsigned int status, unsigned int information ) { struct comp_msg *msg = mem_alloc( sizeof( *msg ) ); diff --git a/server/file.h b/server/file.h index 4255017845c..00b1fa7a4e0 100644 --- a/server/file.h +++ b/server/file.h @@ -125,7 +125,7 @@ extern struct object *create_dir_obj( struct fd *fd ); extern struct completion *get_completion_obj( struct process *process, obj_handle_t handle, unsigned int access ); extern void add_completion( struct completion *completion, apc_param_t ckey, apc_param_t cvalue, - unsigned int status, unsigned long information ); + unsigned int status, unsigned int information ); /* serial port functions */ @@ -138,7 +138,7 @@ extern void free_async_queue( struct async_queue *queue ); extern struct async *create_async( struct thread *thread, struct async_queue *queue, const async_data_t *data ); 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, unsigned long total ); +extern void async_set_result( struct object *obj, unsigned int status, unsigned int total ); extern int async_waiting( struct async_queue *queue ); extern void async_terminate( struct async *async, unsigned int status ); extern void async_wake_up( struct async_queue *queue, unsigned int status ); diff --git a/server/protocol.def b/server/protocol.def index c99ea2e47e5..30654fae8fb 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -289,7 +289,7 @@ typedef union struct { enum apc_type type; /* APC_ASYNC_IO */ - unsigned int (*func)(void*, void*, unsigned int, unsigned long *); + unsigned int (*func)(void*, void*, unsigned int, unsigned int *); void *user; /* user pointer */ void *sb; /* status block */ unsigned int status; /* I/O status */ @@ -374,7 +374,7 @@ typedef union { enum apc_type type; /* APC_ASYNC_IO */ unsigned int status; /* new status of async operation */ - unsigned long total; /* bytes transferred */ + unsigned int total; /* bytes transferred */ } async_io; struct { @@ -3034,7 +3034,7 @@ enum message_type obj_handle_t handle; /* port handle */ apc_param_t ckey; /* completion key */ apc_param_t cvalue; /* completion value */ - unsigned long information; /* IO_STATUS_BLOCK Information */ + unsigned int information; /* IO_STATUS_BLOCK Information */ unsigned int status; /* completion result */ @END @@ -3045,7 +3045,7 @@ enum message_type @REPLY apc_param_t ckey; /* completion key */ apc_param_t cvalue; /* completion value */ - unsigned long information; /* IO_STATUS_BLOCK Information */ + unsigned int information; /* IO_STATUS_BLOCK Information */ unsigned int status; /* completion result */ @END @@ -3071,7 +3071,7 @@ enum message_type obj_handle_t handle; /* async' object */ apc_param_t cvalue; /* completion value */ unsigned int status; /* completion status */ - unsigned long information; /* IO_STATUS_BLOCK Information */ + unsigned int information; /* IO_STATUS_BLOCK Information */ @END diff --git a/server/trace.c b/server/trace.c index 31afbb0b1de..89dbb8c6ed6 100644 --- a/server/trace.c +++ b/server/trace.c @@ -3745,7 +3745,7 @@ static void dump_add_completion_request( const struct add_completion_request *re fprintf( stderr, " handle=%04x,", req->handle ); fprintf( stderr, " ckey=%lx,", req->ckey ); fprintf( stderr, " cvalue=%lx,", req->cvalue ); - fprintf( stderr, " information=%lx,", req->information ); + fprintf( stderr, " information=%08x,", req->information ); fprintf( stderr, " status=%08x", req->status ); } @@ -3758,7 +3758,7 @@ static void dump_remove_completion_reply( const struct remove_completion_reply * { fprintf( stderr, " ckey=%lx,", req->ckey ); fprintf( stderr, " cvalue=%lx,", req->cvalue ); - fprintf( stderr, " information=%lx,", req->information ); + fprintf( stderr, " information=%08x,", req->information ); fprintf( stderr, " status=%08x", req->status ); } @@ -3784,7 +3784,7 @@ static void dump_add_fd_completion_request( const struct add_fd_completion_reque fprintf( stderr, " handle=%04x,", req->handle ); fprintf( stderr, " cvalue=%lx,", req->cvalue ); fprintf( stderr, " status=%08x,", req->status ); - fprintf( stderr, " information=%lx", req->information ); + fprintf( stderr, " information=%08x", req->information ); } static void dump_get_window_layered_info_request( const struct get_window_layered_info_request *req ) diff --git a/tools/make_requests b/tools/make_requests index 2203e5ac300..5d8103e5318 100755 --- a/tools/make_requests +++ b/tools/make_requests @@ -29,7 +29,6 @@ my %formats = "unsigned char" => [ 1, 1, "%02x" ], "unsigned short"=> [ 2, 2, "%04x" ], "unsigned int" => [ 4, 4, "%08x" ], - "unsigned long" => [ 4, 4, "%lx" ], "void*" => [ 4, 4, "%p" ], "data_size_t" => [ 4, 4, "%u" ], "obj_handle_t" => [ 4, 4, "%04x" ],