From 1aa6826f62880be761834bc1317ac0cb8dc398f4 Mon Sep 17 00:00:00 2001 From: Niels Provos Date: Fri, 25 Jul 2008 01:18:40 +0000 Subject: [PATCH] fix off by one errors in devpoll; from Ian Bell svn:r921 --- ChangeLog | 2 ++ devpoll.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 34def828..e9b61f48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 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 off-by-one errors in devpoll; from Ian Bell + 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 demote most http warnings to debug messages diff --git a/devpoll.c b/devpoll.c index c40a718d..2fbb03ca 100644 --- a/devpoll.c +++ b/devpoll.c @@ -137,7 +137,7 @@ devpoll_init(struct event_base *base) if (getrlimit(RLIMIT_NOFILE, &rl) == 0 && rl.rlim_cur != RLIM_INFINITY) - nfiles = rl.rlim_cur - 1; + nfiles = rl.rlim_cur; /* Initialize the kernel queue */ 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; - if (max > devpollop->nfds) { + if (max >= devpollop->nfds) { struct evdevpoll *fds; int nfds; nfds = devpollop->nfds; - while (nfds < max) + while (nfds <= max) nfds <<= 1; fds = mm_realloc(devpollop->fds, nfds * sizeof(struct evdevpoll)); -- 2.40.0