Browse Source

finish epoll move to edge triggering

master
Felix von Leitner 7 years ago
parent
commit
44bcab1661
  1. 6
      io/io_canread.c
  2. 4
      io/io_canwrite.c
  3. 2
      io/io_eagain.c
  4. 7
      io/io_fd.c
  5. 8
      io/io_timeouted.c
  6. 2
      io/io_tryread.c
  7. 2
      io/io_trywrite.c

6
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)

4
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));

2
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;

7
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 &&

8
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 (;ptr<alen; ++ptr,++e) {
if (e->inuse && 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 */

2
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;

2
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;

Loading…
Cancel
Save