From 7001d6ed341e23bf9451f0dfee2b190eb193a64e Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Tue, 29 Mar 2005 11:40:10 +0000 Subject: [PATCH] Clean-up async IO internal functions. --- server/fd.c | 16 ++++++++-------- server/file.c | 2 +- server/file.h | 6 +++--- server/serial.c | 2 +- server/sock.c | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/server/fd.c b/server/fd.c index 0dcaee7d85..ef5b31cf41 100644 --- a/server/fd.c +++ b/server/fd.c @@ -251,7 +251,8 @@ struct timeout_user 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 @@ void unlock_fd( struct fd *fd, file_pos_t start, file_pos_t count ) 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 @@ static void async_callback(void *private) } /* 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 @@ struct async *create_async(struct fd *fd, struct thread *thread, int timeout, st 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 3971182c87..2ce538c020 100644 --- a/server/file.c +++ b/server/file.c @@ -296,7 +296,7 @@ static void file_queue_async( struct fd *fd, void *apc, void *user, void *iosb, 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 1e4907343d..fc65810a46 100644 --- a/server/file.h +++ b/server/file.h @@ -79,12 +79,12 @@ struct timeout_user; 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 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 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 1ad7461e89..6f90f5f3a3 100644 --- a/server/serial.c +++ b/server/serial.c @@ -267,7 +267,7 @@ static void serial_queue_async( struct fd *fd, void *apc, void *user, void *iosb 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 d29233c279..f3f27fc6cd 100644 --- a/server/sock.c +++ b/server/sock.c @@ -528,7 +528,7 @@ static void sock_queue_async( struct fd *fd, void *apc, void *user, void *iosb, } else { - if (!create_async( fd, current, 0, queue, apc, user, iosb )) + if (!create_async( current, 0, queue, apc, user, iosb )) return; } -- 2.32.0.93.g670b81a890