Treat events with fd == -1 as addable.

This turns out to simplify a fair bit of logic, including the bufferevent
code, and should fix bug 2850656.

svn:r1431
This commit is contained in:
Nick Mathewson 2009-09-11 21:02:19 +00:00
parent 85255a6397
commit c2ead9f173
2 changed files with 7 additions and 0 deletions

View File

@ -20,6 +20,7 @@ Changes in 2.0.3-alpha:
o If the kernel tells us that there are a negative number of bytes to read from a socket, do not believe it. Fixes bug 2841177; found by Alexander Pronchenkov.
o Do not detect whether we have monotonic clock support every time a new event base is created: instead do it only once. Patch taken from Chromium.
o Do not allocate the maximum event queue for the epoll backend at startup. Instead, start out accepting 32 events at a time, and double the queue's size when it seems that the OS is generating events faster than we're requesting them. Saves up to 374K per epoll-based event_base. Resolves bug 2839240.
o Treat an event with a negative fd as valid but untriggerable by Libevent. This is useful for applications that want to manually activate events.
Changes in 2.0.2-alpha:

View File

@ -267,6 +267,9 @@ evmap_io_add(struct event_base *base, int fd, struct event *ev)
/*XXX(nickm) Should we assert that ev is not already inserted, or should
* we make this function idempotent? */
if (fd < 0)
return 0;
#ifndef EVMAP_USE_HT
if (fd >= io->nentries) {
if (evmap_make_space(io, fd, sizeof(struct evmap_io *)) == -1)
@ -319,6 +322,9 @@ evmap_io_del(struct event_base *base, int fd, struct event *ev)
int nread, nwrite;
short res = 0, old = 0;
if (fd < 0)
return 0;
assert(fd == ev->ev_fd); /*XXX(nickm) always true? */
/*XXX(nickm) Should we assert that ev is not already inserted, or should
* we make this function idempotent? */