fix off by one errors in devpoll; from Ian Bell

svn:r921
This commit is contained in:
Niels Provos 2008-07-25 01:18:40 +00:00
parent 3b24f4eedc
commit 1aa6826f62
2 changed files with 5 additions and 3 deletions

View File

@ -119,6 +119,8 @@ Changes in current version:
o Fix a bug where deleting signals with the kqueue backend would cause subsequent adds to fail o Fix a bug where deleting signals with the kqueue backend would cause subsequent adds to fail
o Support multiple events listening on the same signal; make signals regular events that go on the same event queue; problem report by Alexander Drozdov. o Support multiple events listening on the same signal; make signals regular events that go on the same event queue; problem report by Alexander Drozdov.
o Fix a problem with epoll() and reinit; problem report by Alexander Drozdov. o Fix a problem with epoll() and reinit; problem report by Alexander Drozdov.
o Fix off-by-one errors in devpoll; from Ian Bell
Changes in 1.4.0: Changes in 1.4.0:
o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr. o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr.
o demote most http warnings to debug messages o demote most http warnings to debug messages

View File

@ -137,7 +137,7 @@ devpoll_init(struct event_base *base)
if (getrlimit(RLIMIT_NOFILE, &rl) == 0 && if (getrlimit(RLIMIT_NOFILE, &rl) == 0 &&
rl.rlim_cur != RLIM_INFINITY) rl.rlim_cur != RLIM_INFINITY)
nfiles = rl.rlim_cur - 1; nfiles = rl.rlim_cur;
/* Initialize the kernel queue */ /* Initialize the kernel queue */
if ((dpfd = open("/dev/poll", O_RDWR)) == -1) { if ((dpfd = open("/dev/poll", O_RDWR)) == -1) {
@ -185,12 +185,12 @@ devpoll_recalc(struct event_base *base, void *arg, int max)
{ {
struct devpollop *devpollop = arg; struct devpollop *devpollop = arg;
if (max > devpollop->nfds) { if (max >= devpollop->nfds) {
struct evdevpoll *fds; struct evdevpoll *fds;
int nfds; int nfds;
nfds = devpollop->nfds; nfds = devpollop->nfds;
while (nfds < max) while (nfds <= max)
nfds <<= 1; nfds <<= 1;
fds = mm_realloc(devpollop->fds, nfds * sizeof(struct evdevpoll)); fds = mm_realloc(devpollop->fds, nfds * sizeof(struct evdevpoll));