From 963fa817de9bcf1a359da5ee15fc680887d96b02 Mon Sep 17 00:00:00 2001 From: leitner Date: Sun, 19 Oct 2003 16:38:31 +0000 Subject: [PATCH] guard against one descriptor being flagged twice --- io/io_canread.c | 1 + io/io_canwrite.c | 1 + io/io_waituntil2.c | 12 ++++++------ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/io/io_canread.c b/io/io_canread.c index 7c4c35d..8c1a26c 100644 --- a/io/io_canread.c +++ b/io/io_canread.c @@ -32,6 +32,7 @@ int64 io_canread() { alt_firstread=r; debug_printf(("io_canread: enqueue %ld in alt read queue (next is %ld)\n",alt_firstread,e->next_read)); #endif + e->canread=0; return r; } } diff --git a/io/io_canwrite.c b/io/io_canwrite.c index 9865aac..db294b3 100644 --- a/io/io_canwrite.c +++ b/io/io_canwrite.c @@ -32,6 +32,7 @@ int64 io_canwrite() { alt_firstwrite=r; debug_printf(("io_canwrite: enqueue %ld in alt write queue (next is %ld)\n",alt_firstwrite,e->next_write)); #endif + e->canwrite=0; return r; } } diff --git a/io/io_waituntil2.c b/io/io_waituntil2.c index b3a06f0..7bda598 100644 --- a/io/io_waituntil2.c +++ b/io/io_waituntil2.c @@ -27,12 +27,12 @@ int64 io_waituntil2(int64 milliseconds) { for (i=n-1; i>=0; --i) { io_entry* e=array_get(&io_fds,sizeof(io_entry),y[i].data.fd); if (e) { - if (y[i].events&EPOLLIN) { + if (!e->canread && (y[i].events&EPOLLIN)) { e->canread=1; e->next_read=first_readable; first_readable=y[i].data.fd; } - if (y[i].events&EPOLLOUT) { + if (!e->canwrite && (y[i].events&EPOLLOUT)) { e->canwrite=1; e->next_write=first_writeable; first_writeable=y[i].data.fd; @@ -54,12 +54,12 @@ int64 io_waituntil2(int64 milliseconds) { for (i=n-1; i>=0; --i) { io_entry* e=array_get(&io_fds,sizeof(io_entry),y[--n].ident); if (e) { - if (y[n].filter==EVFILT_READ) { + if (!e->canread && (y[n].filter==EVFILT_READ)) { e->canread=1; e->next_read=first_readable; first_readable=y[n].ident; } - if (y[n].filter==EVFILT_WRITE) { + if (!e->canwrite && (y[n].filter==EVFILT_WRITE)) { e->canwrite=1; e->next_write=first_writeable; first_writeable=y[i].ident; @@ -134,12 +134,12 @@ again: } for (j=r-1; j>=0; --j) { io_entry* e=array_get(&io_fds,sizeof(io_entry),p->fd); - if (p->revents&POLLIN) { + if (!e->canread && (p->revents&POLLIN)) { e->canread=1; e->next_read=first_readable; first_readable=p->fd; } - if (p->revents&POLLOUT) { + if (!e->canwrite && (p->revents&POLLOUT)) { e->canwrite=1; e->next_write=first_writeable; first_writeable=p->fd;