Clean-up async IO internal functions.
diff --git a/server/fd.c b/server/fd.c index 0dcaee7..ef5b31c 100644 --- a/server/fd.c +++ b/server/fd.c
@@ -251,7 +251,8 @@ static struct list timeout_list = LIST_INIT(timeout_list); /* sorted timeouts list */ /* add a timeout user */ -struct timeout_user *add_timeout_user( struct timeval *when, timeout_callback func, void *private ) +struct timeout_user *add_timeout_user( const struct timeval *when, timeout_callback func, + void *private ) { struct timeout_user *user; struct list *ptr; @@ -987,12 +988,10 @@ struct async { - struct fd *fd; struct thread *thread; void *apc; void *user; void *sb; - struct timeval when; struct timeout_user *timeout; struct list entry; }; @@ -1022,14 +1021,13 @@ } /* create an async on a given queue of a fd */ -struct async *create_async(struct fd *fd, struct thread *thread, int timeout, struct list *queue, +struct async *create_async(struct thread *thread, int* timeout, struct list *queue, void *io_apc, void *io_user, void* io_sb) { struct async *async = mem_alloc( sizeof(struct async) ); if (!async) return NULL; - async->fd = fd; async->thread = (struct thread *)grab_object(thread); async->apc = io_apc; async->user = io_user; @@ -1039,9 +1037,11 @@ if (timeout) { - gettimeofday( &async->when, 0 ); - add_timeout( &async->when, timeout ); - async->timeout = add_timeout_user( &async->when, async_callback, async ); + struct timeval when; + + gettimeofday( &when, 0 ); + add_timeout( &when, *timeout ); + async->timeout = add_timeout_user( &when, async_callback, async ); } else async->timeout = NULL;
diff --git a/server/file.c b/server/file.c index 3971182..2ce538c 100644 --- a/server/file.c +++ b/server/file.c
@@ -296,7 +296,7 @@ return; } - if (!create_async( fd, current, 0, queue, apc, user, iosb )) + if (!create_async( current, 0, queue, apc, user, iosb )) return; /* Check if the new pending request can be served immediately */
diff --git a/server/file.h b/server/file.h index 1e49073..fc65810 100644 --- a/server/file.h +++ b/server/file.h
@@ -79,12 +79,12 @@ typedef void (*timeout_callback)( void *private ); -extern struct timeout_user *add_timeout_user( struct timeval *when, +extern struct timeout_user *add_timeout_user( const struct timeval *when, timeout_callback func, void *private ); extern void remove_timeout_user( struct timeout_user *user ); extern void add_timeout( struct timeval *when, int timeout ); /* return 1 if t1 is before t2 */ -static inline int time_before( struct timeval *t1, struct timeval *t2 ) +static inline int time_before( const struct timeval *t1, const struct timeval *t2 ) { return ((t1->tv_sec < t2->tv_sec) || ((t1->tv_sec == t2->tv_sec) && (t1->tv_usec < t2->tv_usec))); @@ -111,7 +111,7 @@ extern struct object *create_serial( struct fd *fd, unsigned int options ); /* async I/O functions */ -extern struct async *create_async( struct fd *fd, struct thread *thread, int timeout, +extern struct async *create_async( struct thread *thread, int* timeout, struct list *queue, void *, void *, void *); extern void async_terminate_head( struct list *queue, int status );
diff --git a/server/serial.c b/server/serial.c index 1ad7461..6f90f5f 100644 --- a/server/serial.c +++ b/server/serial.c
@@ -267,7 +267,7 @@ return; } - if (!create_async( fd, current, timeout, queue, apc, user, iosb )) + if (!create_async( current, &timeout, queue, apc, user, iosb )) return; /* Check if the new pending request can be served immediately */
diff --git a/server/sock.c b/server/sock.c index d29233c..f3f27fc 100644 --- a/server/sock.c +++ b/server/sock.c
@@ -528,7 +528,7 @@ } else { - if (!create_async( fd, current, 0, queue, apc, user, iosb )) + if (!create_async( current, 0, queue, apc, user, iosb )) return; }