diff --git a/server/fd.c b/server/fd.c index 7806baef038..319f55ca65b 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 *thread, int* timeout, struct list *que 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, int event ) 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 6bbf9b03e24..68cbb3eb87c 100644 --- a/server/file.h +++ b/server/file.h @@ -66,7 +66,8 @@ extern void default_fd_remove_queue( struct object *obj, struct wait_queue_entry 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 3ff6b5c5deb..57a15b59ef5 100644 --- a/server/mailslot.c +++ b/server/mailslot.c @@ -249,7 +249,6 @@ static void mailslot_queue_async( struct fd *fd, void *apc, void *user, 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 fd *fd, void *apc, void *user, 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 5c4da771324..202cf68d079 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 859202cde8b..cc3086c110e 100644 --- a/server/serial.c +++ b/server/serial.c @@ -246,6 +246,7 @@ static void serial_queue_async( struct fd *fd, void *apc, void *user, void *iosb { 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 fd *fd, void *apc, void *user, void *iosb 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 ) );