From 51202765fedea5d67cbc2f196bf6065d08c53dec Mon Sep 17 00:00:00 2001 From: leitner Date: Sat, 25 Apr 2009 19:09:27 +0000 Subject: [PATCH] the #define extern hack in io_fd.c also included time.h, fix that catch case in timeout loop where we have something to report on an fd; in that case do not report a timeout but let the other event get through first. --- io/io_fd.c | 4 ++-- io/io_timeouted.c | 6 +++++- io_internal.h | 5 +++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/io/io_fd.c b/io/io_fd.c index 5256b3e..d87072f 100644 --- a/io/io_fd.c +++ b/io/io_fd.c @@ -1,8 +1,8 @@ #define _GNU_SOURCE #include -#define extern +#define my_extern #include "io_internal.h" -#undef extern +#undef my_extern #include "byte.h" #ifdef HAVE_SIGIO #include diff --git a/io/io_timeouted.c b/io/io_timeouted.c index 08732a1..1028d11 100644 --- a/io/io_timeouted.c +++ b/io/io_timeouted.c @@ -11,8 +11,12 @@ int64 io_timeouted() { e=array_get(&io_fds,sizeof(io_entry),ptr); if (!e) return -1; for (;ptrinuse && e->timeout.sec.x && taia_less(&e->timeout,&now)) + if (e->inuse && e->timeout.sec.x && taia_less(&e->timeout,&now)) { + /* we have a timeout */ + if ((e->canread&&e->wantread) || (e->canwrite&&e->wantwrite)) + continue; /* don't count it if we can signal something else */ return ptr; + } } ptr=-1; /* this is for really pathological cases, where more connections come in all the time and so the timeout diff --git a/io_internal.h b/io_internal.h index 5343a21..53cdcc5 100644 --- a/io_internal.h +++ b/io_internal.h @@ -1,3 +1,8 @@ +#ifndef my_extern +#define my_extern extern +#endif +#undef my_extern + #include "io.h" #include "array.h" #ifdef __MINGW32__