mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-15 07:15:03 -04:00
from trunk: fix off by one errors in devpoll; from Ian Bell
svn:r922
This commit is contained in:
parent
975b102180
commit
534f6657f8
@ -13,6 +13,7 @@ Changes in 1.4.6-stable:
|
|||||||
o Fix a memory leak when using signals for some event bases; reported by Alexander Drozdov.
|
o Fix a memory leak when using signals for some event bases; reported by Alexander Drozdov.
|
||||||
o Add libevent.vcproj file to distribution to help with Windows build.
|
o Add libevent.vcproj file to distribution to help with Windows build.
|
||||||
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.5-stable:
|
Changes in 1.4.5-stable:
|
||||||
o Fix connection keep-alive behavior for HTTP/1.0
|
o Fix connection keep-alive behavior for HTTP/1.0
|
||||||
|
@ -139,7 +139,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) {
|
||||||
@ -187,12 +187,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 = realloc(devpollop->fds, nfds * sizeof(struct evdevpoll));
|
fds = realloc(devpollop->fds, nfds * sizeof(struct evdevpoll));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user