diff --git a/io/io_canread.c b/io/io_canread.c index a6c8fa5..a26d985 100644 --- a/io/io_canread.c +++ b/io/io_canread.c @@ -12,7 +12,7 @@ void io_wantread_really(int64 d, io_entry* e); int64 io_canread() { io_entry* e; if (first_readable==-1) -#ifdef HAVE_SIGIO +#if defined(HAVE_SIGIO) || defined(HAVE_EPOLL) { if (alt_firstread>=0 && (e=iarray_get(&io_fds,alt_firstread)) && e->canread) { debug_printf(("io_canread: normal read queue is empty, swapping in alt read queue (starting with %ld)\n",alt_firstread)); @@ -44,11 +44,11 @@ int64 io_canread() { e->canread #endif ) { -#ifdef HAVE_SIGIO +#if defined(HAVE_SIGIO) || defined(HAVE_EPOLL) e->next_read=alt_firstread; alt_firstread=r; debug_printf(("io_canread: enqueue %ld in alt read queue (next is %ld)\n",alt_firstread,e->next_read)); - if (io_waitmode!=_SIGIO) + if (io_waitmode!=_SIGIO && io_waitmode!=EPOLL) #endif e->canread=0; if (!e->kernelwantread) diff --git a/io/io_canwrite.c b/io/io_canwrite.c index 0495e5f..1f9c465 100644 --- a/io/io_canwrite.c +++ b/io/io_canwrite.c @@ -8,7 +8,7 @@ void io_wantwrite_really(int64 d, io_entry* e); int64 io_canwrite() { io_entry* e; if (first_writeable==-1) -#ifdef HAVE_SIGIO +#if defined(HAVE_SIGIO) || defined(HAVE_EPOLL) { if (alt_firstwrite>=0 && (e=iarray_get(&io_fds,alt_firstwrite)) && e->canwrite) { debug_printf(("io_canwrite: normal write queue is empty, swapping in alt write queue (starting with %ld)\n",alt_firstwrite)); @@ -35,7 +35,7 @@ int64 io_canwrite() { e->canwrite #endif ) { -#ifdef HAVE_SIGIO +#if defined(HAVE_SIGIO) || defined(HAVE_EPOLL) e->next_write=alt_firstwrite; alt_firstwrite=r; debug_printf(("io_canwrite: enqueue %ld in alt write queue (next is %ld)\n",alt_firstwrite,e->next_write)); diff --git a/io/io_eagain.c b/io/io_eagain.c index 2bc7252..d28ee2d 100644 --- a/io/io_eagain.c +++ b/io/io_eagain.c @@ -5,7 +5,7 @@ void io_eagain(int64 d) { if (e) { if (e->wantread) e->canread=0; if (e->wantwrite) e->canwrite=0; -#ifdef HAVE_SIGIO +#if defined(HAVE_SIGIO) || defined(HAVE_EPOLL) if (d==alt_firstread) { debug_printf(("io_eagain: dequeueing %lld from alt read queue (next is %ld)\n",d,e->next_read)); alt_firstread=e->next_read; diff --git a/io/io_fd.c b/io/io_fd.c index da7b5c8..ab83f8c 100644 --- a/io/io_fd.c +++ b/io/io_fd.c @@ -46,7 +46,8 @@ int io_master; #if defined(HAVE_SIGIO) int io_signum; sigset_t io_ss; - +#endif +#if defined(HAVE_SIGIO) || defined(HAVE_EPOLL) long alt_firstread; long alt_firstwrite; #endif @@ -97,8 +98,10 @@ static io_entry* io_fd_internal(int64 d) { if (io_master!=-1) io_waitmode=DEVPOLL; } #endif -#if defined(HAVE_SIGIO) +#if defined(HAVE_SIGIO) || defined(HAVE_EPOLL) alt_firstread=alt_firstwrite=-1; +#endif +#if defined(HAVE_SIGIO) if (io_waitmode==UNDECIDED) { io_signum=SIGRTMIN+1; if (sigemptyset(&io_ss)==0 && diff --git a/io/io_timeouted.c b/io/io_timeouted.c index 9cdb4ea..abd26b5 100644 --- a/io/io_timeouted.c +++ b/io/io_timeouted.c @@ -7,11 +7,11 @@ int64 io_timeouted() { size_t alen=iarray_length(&io_fds); taia_now(&now); ++ptr; - if (ptr>=alen) ptr=0; + if (ptr>alen) ptr=0; e=iarray_get(&io_fds,ptr); - if (!e) return -1; - for (;ptrinuse && e->timeout.sec.x && taia_less(&e->timeout,&now)) { +// if (!e) return -1; + for (;ptr<=alen; ++ptr,e=iarray_get(&io_fds,ptr)) { + if (e && 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 */ diff --git a/io/io_tryread.c b/io/io_tryread.c index 82c823d..5b43cde 100644 --- a/io/io_tryread.c +++ b/io/io_tryread.c @@ -112,7 +112,7 @@ int64 io_tryread(int64 d,char* buf,int64 len) { } if (r==-1 || r==0) { e->canread=0; -#ifdef HAVE_SIGIO +#if defined(HAVE_SIGIO) || defined(HAVE_EPOLL) if (d==alt_firstread) { debug_printf(("io_tryread: dequeueing %ld from alt read queue (next is %ld)\n",d,e->next_read)); alt_firstread=e->next_read; diff --git a/io/io_trywrite.c b/io/io_trywrite.c index b593eec..08f6ed8 100644 --- a/io/io_trywrite.c +++ b/io/io_trywrite.c @@ -106,7 +106,7 @@ int64 io_trywrite(int64 d,const char* buf,int64 len) { } if (r==-1 || r==0) { e->canwrite=0; -#ifdef HAVE_SIGIO +#if defined(HAVE_SIGIO) || defined(HAVE_EPOLL) if (d==alt_firstwrite) { debug_printf(("io_trywrite: dequeueing %ld from alt write queue (next is %ld)\n",d,e->next_write)); alt_firstwrite=e->next_write;