Fix a lot of bad assumptions in the epoll code (this needs major testing).
This commit is contained in:
parent
adb3f9d000
commit
66df8c7271
1 changed files with 22 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* ircd-ratbox: A slightly useful ircd.
|
* charybdis: A slightly useful ircd.
|
||||||
* epoll.c: Linux epoll compatible network routines.
|
* epoll.c: Linux epoll compatible network routines.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
|
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
* Copyright (C) 2001 Adrian Chadd <adrian@creative.net.au>
|
* Copyright (C) 2001 Adrian Chadd <adrian@creative.net.au>
|
||||||
* Copyright (C) 2002-2005 ircd-ratbox development team
|
* Copyright (C) 2002-2005 ircd-ratbox development team
|
||||||
* Copyright (C) 2002 Aaron Sethman <androsyn@ratbox.org>
|
* Copyright (C) 2002 Aaron Sethman <androsyn@ratbox.org>
|
||||||
|
* Copyright (C) 2008 William Pitcock <nenolod@sacredspiral.co.uk>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -133,8 +134,6 @@ comm_setselect(int fd, fdlist_t list, unsigned int type, PF * handler,
|
||||||
libcharybdis_log("comm_setselect(): epoll_ctl failed: %s", strerror(errno));
|
libcharybdis_log("comm_setselect(): epoll_ctl failed: %s", strerror(errno));
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -178,7 +177,6 @@ comm_select(unsigned long delay)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
libcharybdis_log("epoll.c: NULL read handler called");
|
libcharybdis_log("epoll.c: NULL read handler called");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -198,15 +196,30 @@ comm_select(unsigned long delay)
|
||||||
libcharybdis_log("epoll.c: NULL write handler called");
|
libcharybdis_log("epoll.c: NULL write handler called");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(F->flags.open == 0)
|
if(F->flags.open == 0 && F->pflags == 0)
|
||||||
continue;
|
continue;
|
||||||
|
else if (F->flags.open == 0)
|
||||||
|
{
|
||||||
|
F->pflags = ep_event.events = flags;
|
||||||
|
ep_event.data.ptr = F;
|
||||||
|
|
||||||
|
if(epoll_ctl(ep, EPOLL_CTL_DEL, F->fd, &ep_event) != 0) {
|
||||||
|
libcharybdis_log("comm_select(): epoll_ctl failed while trying to delete a closed FD: %s", strerror(errno));
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
|
|
||||||
if(F->read_handler != NULL)
|
if(F->read_handler != NULL)
|
||||||
flags |= EPOLLIN;
|
flags |= EPOLLIN;
|
||||||
|
else
|
||||||
|
flags &= ~EPOLLIN;
|
||||||
|
|
||||||
if(F->write_handler != NULL)
|
if(F->write_handler != NULL)
|
||||||
flags |= EPOLLOUT;
|
flags |= EPOLLOUT;
|
||||||
|
else
|
||||||
|
flags &= ~EPOLLOUT;
|
||||||
|
|
||||||
if(old_flags != flags)
|
if(old_flags != flags)
|
||||||
{
|
{
|
||||||
|
@ -214,12 +227,12 @@ comm_select(unsigned long delay)
|
||||||
op = EPOLL_CTL_DEL;
|
op = EPOLL_CTL_DEL;
|
||||||
else
|
else
|
||||||
op = EPOLL_CTL_MOD;
|
op = EPOLL_CTL_MOD;
|
||||||
|
|
||||||
F->pflags = ep_event.events = flags;
|
F->pflags = ep_event.events = flags;
|
||||||
ep_event.data.ptr = F;
|
ep_event.data.ptr = F;
|
||||||
|
|
||||||
if(epoll_ctl(ep, op, F->fd, &ep_event) != 0)
|
if(epoll_ctl(ep, op, F->fd, &ep_event) != 0)
|
||||||
{
|
libcharybdis_log("comm_select(): epoll_ctl failed: %s", strerror(errno));
|
||||||
libcharybdis_log("comm_setselect(): epoll_ctl failed: %s", strerror(errno));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue