finish epoll move to edge triggering

master
leitner 11 years ago
parent 0f6e586fc9
commit 5baf943f0a

@ -12,7 +12,7 @@ void io_wantread_really(int64 d, io_entry* e);
int64 io_canread() { int64 io_canread() {
io_entry* e; io_entry* e;
if (first_readable==-1) 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) { 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)); 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 e->canread
#endif #endif
) { ) {
#ifdef HAVE_SIGIO #if defined(HAVE_SIGIO) || defined(HAVE_EPOLL)
e->next_read=alt_firstread; e->next_read=alt_firstread;
alt_firstread=r; alt_firstread=r;
debug_printf(("io_canread: enqueue %ld in alt read queue (next is %ld)\n",alt_firstread,e->next_read)); 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 #endif
e->canread=0; e->canread=0;
if (!e->kernelwantread) if (!e->kernelwantread)

@ -8,7 +8,7 @@ void io_wantwrite_really(int64 d, io_entry* e);
int64 io_canwrite() { int64 io_canwrite() {
io_entry* e; io_entry* e;
if (first_writeable==-1) 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) { 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)); 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 e->canwrite
#endif #endif
) { ) {
#ifdef HAVE_SIGIO #if defined(HAVE_SIGIO) || defined(HAVE_EPOLL)
e->next_write=alt_firstwrite; e->next_write=alt_firstwrite;
alt_firstwrite=r; alt_firstwrite=r;
debug_printf(("io_canwrite: enqueue %ld in alt write queue (next is %ld)\n",alt_firstwrite,e->next_write)); debug_printf(("io_canwrite: enqueue %ld in alt write queue (next is %ld)\n",alt_firstwrite,e->next_write));

@ -5,7 +5,7 @@ void io_eagain(int64 d) {
if (e) { if (e) {
if (e->wantread) e->canread=0; if (e->wantread) e->canread=0;
if (e->wantwrite) e->canwrite=0; if (e->wantwrite) e->canwrite=0;
#ifdef HAVE_SIGIO #if defined(HAVE_SIGIO) || defined(HAVE_EPOLL)
if (d==alt_firstread) { if (d==alt_firstread) {
debug_printf(("io_eagain: dequeueing %lld from alt read queue (next is %ld)\n",d,e->next_read)); debug_printf(("io_eagain: dequeueing %lld from alt read queue (next is %ld)\n",d,e->next_read));
alt_firstread=e->next_read; alt_firstread=e->next_read;

@ -46,7 +46,8 @@ int io_master;
#if defined(HAVE_SIGIO) #if defined(HAVE_SIGIO)
int io_signum; int io_signum;
sigset_t io_ss; sigset_t io_ss;
#endif
#if defined(HAVE_SIGIO) || defined(HAVE_EPOLL)
long alt_firstread; long alt_firstread;
long alt_firstwrite; long alt_firstwrite;
#endif #endif
@ -97,8 +98,10 @@ static io_entry* io_fd_internal(int64 d) {
if (io_master!=-1) io_waitmode=DEVPOLL; if (io_master!=-1) io_waitmode=DEVPOLL;
} }
#endif #endif
#if defined(HAVE_SIGIO) #if defined(HAVE_SIGIO) || defined(HAVE_EPOLL)
alt_firstread=alt_firstwrite=-1; alt_firstread=alt_firstwrite=-1;
#endif
#if defined(HAVE_SIGIO)
if (io_waitmode==UNDECIDED) { if (io_waitmode==UNDECIDED) {
io_signum=SIGRTMIN+1; io_signum=SIGRTMIN+1;
if (sigemptyset(&io_ss)==0 && if (sigemptyset(&io_ss)==0 &&

@ -7,11 +7,11 @@ int64 io_timeouted() {
size_t alen=iarray_length(&io_fds); size_t alen=iarray_length(&io_fds);
taia_now(&now); taia_now(&now);
++ptr; ++ptr;
if (ptr>=alen) ptr=0; if (ptr>alen) ptr=0;
e=iarray_get(&io_fds,ptr); e=iarray_get(&io_fds,ptr);
if (!e) return -1; // if (!e) return -1;
for (;ptr<alen; ++ptr,++e) { for (;ptr<=alen; ++ptr,e=iarray_get(&io_fds,ptr)) {
if (e->inuse && e->timeout.sec.x && taia_less(&e->timeout,&now)) { if (e && e->inuse && e->timeout.sec.x && taia_less(&e->timeout,&now)) {
/* we have a timeout */ /* we have a timeout */
if ((e->canread&&e->wantread) || (e->canwrite&&e->wantwrite)) if ((e->canread&&e->wantread) || (e->canwrite&&e->wantwrite))
continue; /* don't count it if we can signal something else */ continue; /* don't count it if we can signal something else */

@ -112,7 +112,7 @@ int64 io_tryread(int64 d,char* buf,int64 len) {
} }
if (r==-1 || r==0) { if (r==-1 || r==0) {
e->canread=0; e->canread=0;
#ifdef HAVE_SIGIO #if defined(HAVE_SIGIO) || defined(HAVE_EPOLL)
if (d==alt_firstread) { if (d==alt_firstread) {
debug_printf(("io_tryread: dequeueing %ld from alt read queue (next is %ld)\n",d,e->next_read)); debug_printf(("io_tryread: dequeueing %ld from alt read queue (next is %ld)\n",d,e->next_read));
alt_firstread=e->next_read; alt_firstread=e->next_read;

@ -106,7 +106,7 @@ int64 io_trywrite(int64 d,const char* buf,int64 len) {
} }
if (r==-1 || r==0) { if (r==-1 || r==0) {
e->canwrite=0; e->canwrite=0;
#ifdef HAVE_SIGIO #if defined(HAVE_SIGIO) || defined(HAVE_EPOLL)
if (d==alt_firstwrite) { if (d==alt_firstwrite) {
debug_printf(("io_trywrite: dequeueing %ld from alt write queue (next is %ld)\n",d,e->next_write)); debug_printf(("io_trywrite: dequeueing %ld from alt write queue (next is %ld)\n",d,e->next_write));
alt_firstwrite=e->next_write; alt_firstwrite=e->next_write;

Loading…
Cancel
Save