summaryrefslogtreecommitdiff
path: root/select.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-05-30 11:53:19 -0400
committerNick Mathewson <nickm@torproject.org>2011-05-30 11:53:19 -0400
commitd90149d4b6fb9273aa363e5a18223250e8721034 (patch)
treefd2d0d886d6088daeb262dcbe15455db98f113d1 /select.c
parentdbb3c65288e219ce3f05efc3fb6c84ff96cf24a9 (diff)
downloadlibevent-d90149d4b6fb9273aa363e5a18223250e8721034.tar.gz
Fix a fencepost bug in the select backend
This bug would sometimes lead us to looking one bit off the end of the fdset arrays, and trying to activate a (nonexistent) event if that bit was set. Found by Harlann Stenn. Fixes a test failure on OpenSolaris.
Diffstat (limited to 'select.c')
-rw-r--r--select.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/select.c b/select.c
index 94956318..892ddfaf 100644
--- a/select.c
+++ b/select.c
@@ -172,9 +172,9 @@ select_dispatch(struct event_base *base, struct timeval *tv)
event_debug(("%s: select reports %d", __func__, res));
check_selectop(sop);
- i = random() % (nfds+1);
- for (j = 0; j <= nfds; ++j) {
- if (++i >= nfds+1)
+ i = random() % nfds;
+ for (j = 0; j < nfds; ++j) {
+ if (++i >= nfds)
i = 0;
res = 0;
if (FD_ISSET(i, sop->event_readset_out))