Module: wine Branch: refs/heads/master Commit: 40723f795ba390b70594f278106af637c9afb8d4 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=40723f795ba390b70594f278...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Jul 26 11:47:42 2006 +0200
server: Make the create_async function take an absolute timeout.
---
server/fd.c | 16 +++++----------- server/file.h | 5 +++-- server/mailslot.c | 12 ++++++++---- server/named_pipe.c | 16 ++++++++-------- server/serial.c | 6 ++++-- 5 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/server/fd.c b/server/fd.c index 7806bae..319f55c 100644 --- a/server/fd.c +++ b/server/fd.c @@ -1116,8 +1116,8 @@ static void async_callback(void *private }
/* create an async on a given queue of a fd */ -struct async *create_async(struct thread *thread, int* timeout, struct list *queue, - void *io_apc, void *io_user, void* io_sb) +struct async *create_async( struct thread *thread, const struct timeval *timeout, + struct list *queue, void *io_apc, void *io_user, void* io_sb ) { struct async *async = mem_alloc( sizeof(struct async) );
@@ -1130,14 +1130,7 @@ struct async *create_async(struct thread
list_add_tail( queue, &async->entry );
- if (timeout) - { - struct timeval when; - - gettimeofday( &when, NULL ); - add_timeout( &when, *timeout ); - async->timeout = add_timeout_user( &when, async_callback, async ); - } + if (timeout) async->timeout = add_timeout_user( timeout, async_callback, async ); else async->timeout = NULL;
return async; @@ -1583,7 +1576,8 @@ void default_poll_event( struct fd *fd, wake_up( fd->user, 0 ); }
-void fd_queue_async_timeout( struct fd *fd, void *apc, void *user, void *io_sb, int type, int count, int *timeout ) +void fd_queue_async_timeout( struct fd *fd, void *apc, void *user, void *io_sb, int type, int count, + const struct timeval *timeout ) { struct list *queue; int events; diff --git a/server/file.h b/server/file.h index 6bbf9b0..68cbb3e 100644 --- a/server/file.h +++ b/server/file.h @@ -66,7 +66,8 @@ extern void default_fd_remove_queue( str extern int default_fd_signaled( struct object *obj, struct thread *thread ); extern int default_fd_get_poll_events( struct fd *fd ); extern void default_poll_event( struct fd *fd, int event ); -extern void fd_queue_async_timeout( struct fd *fd, void *apc, void *user, void *io_sb, int type, int count, int *timeout ); +extern void fd_queue_async_timeout( struct fd *fd, void *apc, void *user, void *io_sb, int type, + int count, const struct timeval *timeout ); extern void default_fd_queue_async( struct fd *fd, void *apc, void *user, void *io_sb, int type, int count ); extern void default_fd_cancel_async( struct fd *fd ); extern int no_flush( struct fd *fd, struct event **event ); @@ -117,7 +118,7 @@ extern int is_serial_fd( struct fd *fd ) extern struct object *create_serial( struct fd *fd, unsigned int options );
/* async I/O functions */ -extern struct async *create_async( struct thread *thread, int* timeout, +extern struct async *create_async( struct thread *thread, const struct timeval *timeout, struct list *queue, void *, void *, void *); extern void async_terminate_head( struct list *queue, int status );
diff --git a/server/mailslot.c b/server/mailslot.c index 3ff6b5c..57a15b5 100644 --- a/server/mailslot.c +++ b/server/mailslot.c @@ -249,7 +249,6 @@ static void mailslot_queue_async( struct void *iosb, int type, int count ) { struct mailslot *mailslot = get_fd_user( fd ); - int *timeout = NULL;
assert(mailslot->obj.ops == &mailslot_ops);
@@ -266,9 +265,14 @@ static void mailslot_queue_async( struct return; }
- if (mailslot->read_timeout != -1) timeout = &mailslot->read_timeout; - - fd_queue_async_timeout( fd, apc, user, iosb, type, count, timeout ); + if (mailslot->read_timeout != -1) + { + struct timeval when; + gettimeofday( &when, NULL ); + add_timeout( &when, mailslot->read_timeout ); + fd_queue_async_timeout( fd, apc, user, iosb, type, count, &when ); + } + else fd_queue_async_timeout( fd, apc, user, iosb, type, count, NULL ); }
static void mailslot_device_dump( struct object *obj, int verbose ) diff --git a/server/named_pipe.c b/server/named_pipe.c index 5c4da77..202cf68 100644 --- a/server/named_pipe.c +++ b/server/named_pipe.c @@ -868,18 +868,18 @@ DECL_HANDLER(wait_named_pipe) } else { - int timeout; - if (req->timeout == NMPWAIT_USE_DEFAULT_WAIT) - timeout = pipe->timeout; - else - timeout = req->timeout; - if (req->timeout == NMPWAIT_WAIT_FOREVER) create_async( current, NULL, &pipe->waiters, req->func, req->event, NULL ); else - create_async( current, &timeout, &pipe->waiters, - req->func, req->event, NULL ); + { + struct timeval when; + + gettimeofday( &when, NULL ); + if (req->timeout == NMPWAIT_USE_DEFAULT_WAIT) add_timeout( &when, pipe->timeout ); + else add_timeout( &when, req->timeout ); + create_async( current, &when, &pipe->waiters, req->func, req->event, NULL ); + } }
release_object( pipe ); diff --git a/server/serial.c b/server/serial.c index 859202c..cc3086c 100644 --- a/server/serial.c +++ b/server/serial.c @@ -246,6 +246,7 @@ static void serial_queue_async( struct f { struct serial *serial = get_fd_user( fd ); struct list *queue; + struct timeval when; int timeout; int events;
@@ -270,8 +271,9 @@ static void serial_queue_async( struct f return; }
- if (!create_async( current, &timeout, queue, apc, user, iosb )) - return; + gettimeofday( &when, NULL ); + add_timeout( &when, timeout ); + if (!create_async( current, &when, queue, apc, user, iosb )) return;
/* Check if the new pending request can be served immediately */ events = check_fd_events( fd, serial_get_poll_events( fd ) );