Skip to content

Commit

Permalink
fix off by one errors in devpoll; from Ian Bell
Browse files Browse the repository at this point in the history
svn:r921
  • Loading branch information
provos committed Jul 25, 2008
1 parent 3b24f4e commit 1aa6826
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions devpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 1aa6826

Please sign in to comment.