server: Make the create_async function take an absolute timeout.
This commit is contained in:
parent
a624977f21
commit
40723f795b
16
server/fd.c
16
server/fd.c
|
@ -1116,8 +1116,8 @@ static void async_callback(void *private)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create an async on a given queue of a fd */
|
/* create an async on a given queue of a fd */
|
||||||
struct async *create_async(struct thread *thread, int* timeout, struct list *queue,
|
struct async *create_async( struct thread *thread, const struct timeval *timeout,
|
||||||
void *io_apc, void *io_user, void* io_sb)
|
struct list *queue, void *io_apc, void *io_user, void* io_sb )
|
||||||
{
|
{
|
||||||
struct async *async = mem_alloc( sizeof(struct async) );
|
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 );
|
list_add_tail( queue, &async->entry );
|
||||||
|
|
||||||
if (timeout)
|
if (timeout) async->timeout = add_timeout_user( timeout, async_callback, async );
|
||||||
{
|
|
||||||
struct timeval when;
|
|
||||||
|
|
||||||
gettimeofday( &when, NULL );
|
|
||||||
add_timeout( &when, *timeout );
|
|
||||||
async->timeout = add_timeout_user( &when, async_callback, async );
|
|
||||||
}
|
|
||||||
else async->timeout = NULL;
|
else async->timeout = NULL;
|
||||||
|
|
||||||
return async;
|
return async;
|
||||||
|
@ -1583,7 +1576,8 @@ void default_poll_event( struct fd *fd, int event )
|
||||||
wake_up( fd->user, 0 );
|
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;
|
struct list *queue;
|
||||||
int events;
|
int events;
|
||||||
|
|
|
@ -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_signaled( struct object *obj, struct thread *thread );
|
||||||
extern int default_fd_get_poll_events( struct fd *fd );
|
extern int default_fd_get_poll_events( struct fd *fd );
|
||||||
extern void default_poll_event( struct fd *fd, int event );
|
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_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 void default_fd_cancel_async( struct fd *fd );
|
||||||
extern int no_flush( struct fd *fd, struct event **event );
|
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 );
|
extern struct object *create_serial( struct fd *fd, unsigned int options );
|
||||||
|
|
||||||
/* async I/O functions */
|
/* 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 *);
|
struct list *queue, void *, void *, void *);
|
||||||
extern void async_terminate_head( struct list *queue, int status );
|
extern void async_terminate_head( struct list *queue, int status );
|
||||||
|
|
||||||
|
|
|
@ -249,7 +249,6 @@ static void mailslot_queue_async( struct fd *fd, void *apc, void *user,
|
||||||
void *iosb, int type, int count )
|
void *iosb, int type, int count )
|
||||||
{
|
{
|
||||||
struct mailslot *mailslot = get_fd_user( fd );
|
struct mailslot *mailslot = get_fd_user( fd );
|
||||||
int *timeout = NULL;
|
|
||||||
|
|
||||||
assert(mailslot->obj.ops == &mailslot_ops);
|
assert(mailslot->obj.ops == &mailslot_ops);
|
||||||
|
|
||||||
|
@ -266,9 +265,14 @@ static void mailslot_queue_async( struct fd *fd, void *apc, void *user,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mailslot->read_timeout != -1) timeout = &mailslot->read_timeout;
|
if (mailslot->read_timeout != -1)
|
||||||
|
{
|
||||||
fd_queue_async_timeout( fd, apc, user, iosb, type, count, timeout );
|
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 )
|
static void mailslot_device_dump( struct object *obj, int verbose )
|
||||||
|
|
|
@ -868,18 +868,18 @@ DECL_HANDLER(wait_named_pipe)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int timeout;
|
|
||||||
if (req->timeout == NMPWAIT_USE_DEFAULT_WAIT)
|
|
||||||
timeout = pipe->timeout;
|
|
||||||
else
|
|
||||||
timeout = req->timeout;
|
|
||||||
|
|
||||||
if (req->timeout == NMPWAIT_WAIT_FOREVER)
|
if (req->timeout == NMPWAIT_WAIT_FOREVER)
|
||||||
create_async( current, NULL, &pipe->waiters,
|
create_async( current, NULL, &pipe->waiters,
|
||||||
req->func, req->event, NULL );
|
req->func, req->event, NULL );
|
||||||
else
|
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 );
|
release_object( pipe );
|
||||||
|
|
|
@ -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 serial *serial = get_fd_user( fd );
|
||||||
struct list *queue;
|
struct list *queue;
|
||||||
|
struct timeval when;
|
||||||
int timeout;
|
int timeout;
|
||||||
int events;
|
int events;
|
||||||
|
|
||||||
|
@ -270,8 +271,9 @@ static void serial_queue_async( struct fd *fd, void *apc, void *user, void *iosb
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!create_async( current, &timeout, queue, apc, user, iosb ))
|
gettimeofday( &when, NULL );
|
||||||
return;
|
add_timeout( &when, timeout );
|
||||||
|
if (!create_async( current, &when, queue, apc, user, iosb )) return;
|
||||||
|
|
||||||
/* Check if the new pending request can be served immediately */
|
/* Check if the new pending request can be served immediately */
|
||||||
events = check_fd_events( fd, serial_get_poll_events( fd ) );
|
events = check_fd_events( fd, serial_get_poll_events( fd ) );
|
||||||
|
|
Loading…
Reference in New Issue