Alexandre Julliard : server: Make timeout status for async I/O
specifiable. Fix mailslots timeout handling.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Apr 4 12:32:25 CDT 2007
Module: wine
Branch: master
Commit: 4e5c7038da0c6ee3126d7099326b13565e54cec1
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4e5c7038da0c6ee3126d7099326b13565e54cec1
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Apr 3 19:12:31 2007 +0200
server: Make timeout status for async I/O specifiable. Fix mailslots timeout handling.
---
dlls/kernel32/tests/mailslot.c | 2 +-
server/async.c | 6 ++++--
server/file.h | 3 ++-
server/mailslot.c | 20 +-------------------
server/named_pipe.c | 2 +-
server/serial.c | 2 +-
6 files changed, 10 insertions(+), 25 deletions(-)
diff --git a/dlls/kernel32/tests/mailslot.c b/dlls/kernel32/tests/mailslot.c
index 0c47fde..850b065 100644
--- a/dlls/kernel32/tests/mailslot.c
+++ b/dlls/kernel32/tests/mailslot.c
@@ -299,7 +299,7 @@ static int mailslot_test(void)
ok( !ReadFile( hSlot, buffer, sizeof buffer, &count, NULL), "slot read\n");
ok( GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %u\n", GetLastError() );
dwTimeout = GetTickCount() - dwTimeout;
- todo_wine ok( dwTimeout >= 1000, "timeout too short %u\n", dwTimeout );
+ ok( dwTimeout >= 1000, "timeout too short %u\n", dwTimeout );
ok( CloseHandle( hSlot ), "closing the mailslot\n");
return 0;
diff --git a/server/async.c b/server/async.c
index 26221a3..c58ef5f 100644
--- a/server/async.c
+++ b/server/async.c
@@ -38,6 +38,7 @@ struct async
struct thread *thread; /* owning thread */
struct list queue_entry; /* entry in file descriptor queue */
struct timeout_user *timeout;
+ unsigned int timeout_status; /* status to report upon timeout */
struct event *event;
async_data_t data; /* data for async I/O call */
};
@@ -149,7 +150,7 @@ static void async_timeout( void *private )
struct async *async = private;
async->timeout = NULL;
- async_terminate( async, STATUS_TIMEOUT );
+ async_terminate( async, async->timeout_status );
}
/* create a new async queue for a given fd */
@@ -193,11 +194,12 @@ struct async *create_async( struct thread *thread, struct async_queue *queue, co
}
/* set the timeout of an async operation */
-void async_set_timeout( struct async *async, const struct timeval *timeout )
+void async_set_timeout( struct async *async, const struct timeval *timeout, unsigned int status )
{
if (async->timeout) remove_timeout_user( async->timeout );
if (timeout) async->timeout = add_timeout_user( timeout, async_timeout, async );
else async->timeout = NULL;
+ async->timeout_status = status;
}
/* store the result of the client-side async callback */
diff --git a/server/file.h b/server/file.h
index ca2e426..a46a24f 100644
--- a/server/file.h
+++ b/server/file.h
@@ -126,7 +126,8 @@ extern struct object *create_serial( struct fd *fd, unsigned int options );
extern struct async_queue *create_async_queue( struct fd *fd );
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, const struct timeval *timeout );
+extern void async_set_timeout( struct async *async, const struct timeval *timeout,
+ unsigned int status );
extern void async_set_result( struct object *obj, unsigned int status );
extern int async_waiting( struct async_queue *queue );
extern void async_wake_up( struct async_queue *queue, unsigned int status );
diff --git a/server/mailslot.c b/server/mailslot.c
index 227c99f..89af2bf 100644
--- a/server/mailslot.c
+++ b/server/mailslot.c
@@ -208,17 +208,6 @@ static void mailslot_dump( struct object *obj, int verbose )
mailslot->max_msgsize, mailslot->read_timeout );
}
-static int mailslot_message_count(struct mailslot *mailslot)
-{
- struct pollfd pfd;
-
- /* poll the socket to see if there's any messages */
- pfd.fd = get_unix_fd( mailslot->fd );
- pfd.events = POLLIN;
- pfd.revents = 0;
- return (poll( &pfd, 1, 0 ) == 1) ? 1 : 0;
-}
-
static enum server_fd_type mailslot_get_info( struct fd *fd, int *flags )
{
struct mailslot *mailslot = get_fd_user( fd );
@@ -286,20 +275,13 @@ static void mailslot_queue_async( struct fd *fd, const async_data_t *data, int t
assert(mailslot->obj.ops == &mailslot_ops);
- if (list_empty( &mailslot->writers ) ||
- !mailslot_message_count( mailslot ))
- {
- set_error(STATUS_IO_TIMEOUT);
- return;
- }
-
if ((async = fd_queue_async( fd, data, type, count )))
{
if (mailslot->read_timeout != -1)
{
struct timeval when = current_time;
add_timeout( &when, max(1,mailslot->read_timeout) );
- async_set_timeout( async, &when );
+ async_set_timeout( async, &when, STATUS_IO_TIMEOUT );
}
release_object( async );
set_error( STATUS_PENDING );
diff --git a/server/named_pipe.c b/server/named_pipe.c
index 6afcdb6..9136041 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -867,7 +867,7 @@ DECL_HANDLER(wait_named_pipe)
struct timeval when = current_time;
if (req->timeout == NMPWAIT_USE_DEFAULT_WAIT) add_timeout( &when, pipe->timeout );
else add_timeout( &when, req->timeout );
- async_set_timeout( async, &when );
+ async_set_timeout( async, &when, STATUS_TIMEOUT );
}
release_object( async );
set_error( STATUS_PENDING );
diff --git a/server/serial.c b/server/serial.c
index 42a3f72..f2b88c1 100644
--- a/server/serial.c
+++ b/server/serial.c
@@ -219,7 +219,7 @@ static void serial_queue_async( struct fd *fd, const async_data_t *data, int typ
{
struct timeval when = current_time;
add_timeout( &when, timeout );
- async_set_timeout( async, &when );
+ async_set_timeout( async, &when, STATUS_TIMEOUT );
}
release_object( async );
set_error( STATUS_PENDING );
More information about the wine-cvs
mailing list