correctly initialize records before reusing them in io_fd

do something about unexpected epoll events
master
leitner 21 years ago
parent 29ae01d54f
commit eaa4dea67b

@ -2,6 +2,7 @@
#define extern #define extern
#include "io_internal.h" #include "io_internal.h"
#undef extern #undef extern
#include "byte.h"
#ifdef HAVE_SIGIO #ifdef HAVE_SIGIO
#include <sys/poll.h> #include <sys/poll.h>
#include <signal.h> #include <signal.h>
@ -23,9 +24,10 @@
int io_fd(int64 d) { int io_fd(int64 d) {
long r; long r;
io_entry* e; io_entry* e;
if ((r=fcntl(d,F_GETFL,0) & O_NDELAY) == -1) if ((r=fcntl(d,F_GETFL,0)) == -1)
return 0; /* file descriptor not open */ return 0; /* file descriptor not open */
if (!(e=array_allocate(&io_fds,sizeof(io_entry),d))) return 0; if (!(e=array_allocate(&io_fds,sizeof(io_entry),d))) return 0;
byte_zero(e,sizeof(io_entry));
e->inuse=1; e->inuse=1;
if (r&O_NDELAY) e->nonblock=1; if (r&O_NDELAY) e->nonblock=1;
e->next_read=e->next_write=-1; e->next_read=e->next_write=-1;

@ -37,6 +37,8 @@ int64 io_waituntil2(int64 milliseconds) {
e->next_write=first_writeable; e->next_write=first_writeable;
first_writeable=y[i].data.fd; first_writeable=y[i].data.fd;
} }
} else {
epoll_ctl(io_master,EPOLL_CTL_DEL,y[i].data.fd,y+i);
} }
} }
return n; return n;

Loading…
Cancel
Save