evmap.c


Log

Author Commit Date CI Message
Azat Khuzhin d1487831 2018-10-30T23:59:24 Preserve ET bit for backends with changelist [ Upstream commit a1293bd2e626cba1f687cd0e50a219f8661775fc ] Fixes: #636
Isidor Kouvelas 63306e6f 2018-10-30T08:50:08 Epoll ET setting lost with multiple events for same fd [ Upstream commit b77d3e787b5522380c65838d3baa22e661eff0db ] After two or more events have been registered for the same file descriptor using EV_ET, if one of the events is deleted, then the epoll_ctl() call issued by libevent drops the EPOLLET flag resulting in level triggered notifications. [ azat: test for EV_ET for EPOLL_CTL_MOD too, for libevent 2.0 ] Fixes: #636
Maxime Henrion db6c5dfb 2013-05-16T16:38:39 If evsel->del() fails, don't leave the evmap in an inconsistent state. [ Upstream commit 9b5a527f5bf898250a797dde59cadb4f64e8967a ] This fixes assertion failures in cases where epoll() fails with EBADF -- the root cause for which is as of yet unknown. It seems something (OpenSSL?) is closing the file descriptor under our feet.
Nick Mathewson e49e2891 2012-02-10T17:29:53 Update copyright notices to 2012
Nick Mathewson 438d4ff2 2012-01-24T15:29:39 Make event_base integrity check work on windows
Nick Mathewson 27737d55 2012-01-21T12:55:15 Add function to check referential integrity of an event_base
Nick Mathewson 3c824bd3 2011-10-24T13:18:09 Update copyright dates to 2011.
Nick Mathewson 89d5e09e 2011-06-08T14:18:41 Add some missing checks for mm_calloc failures Found by Gilad Benjamini
Nick Mathewson 06a714ff 2011-05-25T16:51:25 Fix new warnings from GCC 4.6
Nick Mathewson b4f89f00 2011-04-21T17:33:13 Fix a memory leak on win32 socket->event map. This would lose some memory every time an event_base was freed on win32. Found by Dimitre Piskyulev.
Nick Mathewson bb0d2b4e 2010-12-09T11:47:54 Consistentize tabs
Nick Mathewson e56ff65a 2010-10-26T11:01:58 Fix a minor syntax error that most compilers didn't care about
Nick Mathewson ec347b92 2010-07-07T16:45:03 Move event-config.h to include/event2 This change means that all required include files are in event2, and all files not in event2/* are optional.
Nick Mathewson cb927a51 2010-07-19T15:03:43 Fix whitespace.
Mike Smellie cf249e7d 2010-07-19T13:44:56 Possible fix to 100% cpu usage with epoll and openssl I'm running a fairly simple bit of test code using libevent2 with epoll and openssl bufferevents and I've run into a 100% cpu usage problem. Looking into it 100% usage was caused by epoll_wait constantly returning write events on the openssl socket when it shouldn't really have been looking for write events at all (N_ACTIVE_CALLBACKS() was returning 0 also). Looking a bit deeper eventbuffer_openssl socket seems to be requesting that the EV_WRITE event be removed when it should, but the event isn't actually being removed from epoll. Continuing to follow this I think I've found a bug in event_changelist_del. For evpoll event_del calls event_changelist_del which caches the change which is then actioned later when evpoll_dispatch is called. In event_changlist_del there is a check so that if the currently changed action is an add then the cached action is changed to a no-op rather than a delete (which makes sense). The problem arises if there are more than two add or delete operations between calls to dispatch, in this case it's possible that the delete is turned into a no-op when it shouldn't have been. For example starting with the event on, a delete followed by an add and then another delete results in a no-op when it should have been a delete (I added a fair bit of debug output that seems to confirm this behaviour). I've applied a small change that checks the original old_event stored with the change and only converts the delete to a no-op if the event isn't on in old_event. This seems to have fixed my problem.
Nick Mathewson cb670740 2010-04-28T11:51:56 Make debug mode catch mixed ET and non-ET events on an fd Of the backends that support edge-triggered IO, most (all?) do not support attempts to mix edge-triggered and level-triggered IO on the same FD. With debugging mode enabled, we now detect and refuse attempts to add a level-triggered IO event to an fd that already has an edge-triggered IO event, and vice versa.
Nick Mathewson 819f949f 2010-04-09T19:16:49 Limit the maximum number of events on each socket to 65535 This lets us use less RAM for the evmap_io structure, which in turn can let us have fewer cache misses for evmap operations.
Nick Mathewson c247adc7 2010-04-09T13:32:08 Add a few more evmap/changelist comments
Patrick Galbraith e1e703d2 2010-03-23T16:04:59 Make evutil_signal_active() match declaration.
Nick Mathewson c7cf6f00 2010-03-05T12:47:46 Replace users of "int fd" with "evutil_socket_t fd" in portable code Remeber, win32 has a socket type that's actually a handle, so if there's a chance that code is run on win32, we can't use "int" as the socket type. This isn't a blind search-and-replace: sometimes an fd is really in fact for a file, and not a socket at all.
Nick Mathewson 17efc1cd 2010-03-04T01:25:51 Update all our copyright notices to say "2010"
Nick Mathewson f6b26949 2010-02-03T01:16:47 Deprecate EVENT_FD and EVENT_SIGNAL. These are old aliases for event_get_fd and event_get_signal, and they haven't been the preferred way of doing things since 2.0.1-alpha. For a while, we made them use struct event if it was included, but call event_get_(fd|signal) if it wasn't. This was entirely too cute.
Nick Mathewson 27308aae 2010-01-14T16:30:40 Changelist code to defer event changes until just before dispatch This is necessary or useful for a few reasons: 1) Sometimes applications will add and delete the same event more than once between calls to dispatch. Processing these changes immediately is needless, and potentially expensive (especially if we're on a system that makes one syscall per changed event). Yes, this actually happens in practice for nonpathological code, such as in cases where the user's callback conditionally re-adds a non-persistent event, or where draining a buffer turns off writing and invokes a user callback which adds more data which in turn re-enabled writing. 2) Sometimes we can coalesce multiple changes on the same fd into a single syscall if we know about them in advance. For example, epoll can do an add and a delete at the same time, but only if we have found out about both of them before we tell epoll. 3) Sometimes adding an event that we immediately delete can cause unintended consequences: in kqueue, this makes pending events get reported spuriously.
Nick Mathewson 784b8773 2009-11-06T21:46:57 We do not work any more without an event-config.h; stop pretending that it is meaningful to check for HAVE_CONFIG_H svn:r1516
Nick Mathewson 0fd0255f 2009-11-03T19:54:56 Remove compat/sys/_time.h I've gone through everything that it declared to see where it was used, and it seems that we probably don't need it anywhere. Here's what it declared, and why I think we're okay dropping it. o struct timeval {} (Used all over, and we can't really get away with declaring it ourselves; we need the same definition the system uses. If we can't find struct timeval, we're pretty much sunk.) o struct timespec {} (Used in event.c, evdns.c, kqueue.c, evport.c. Of these, kqueue.c and event.c include sys/_time.h. event.c conditions its use on _EVENT_HAVE_CLOCK_GETTIME, and kqueue() only works if timespec is defined.) o TIMEVAL_TO_TIMESPEC (Used in kqueue.c, but every place with kqueue has sys/time.h) o struct timezone {} (event2/util.h has a forward declaration; only evutil.c references it and doesn't look at its contents.) o timerclear, timerisset, timercmp, timeradd, timersub (Everything now uses the evutil_timer* variants.) o ITIMER_REAL, ITIMER_VIRTUAL, ITIMER_PROF, struct itemerval (These are only used in test/regress.c, which does not include _time.h) o CLOCK_REALTIME (Only used in evdns.c, which does not include _time.h) o TIMESPEC_TO_TIMEVAL o DST_* o timespecclear, timespecisset, timespeccmp, timespecadd, timespecsub o struct clockinfo {} o CLOCK_VIRTUAL, CLOCK_PROF o TIMER_RELTIME, TIMER_ABSTIME (unused) svn:r1494
Nick Mathewson a2a7d1d1 2009-10-27T05:16:32 Do not call the locking variant of event_add or event_active in some cases when we know we have the lock. svn:r1471
Nick Mathewson 2e36dbe1 2009-10-26T20:00:43 Use EVUTIL_ASSERT() consistently instead of assert. svn:r1464
Nick Mathewson f3dee9e8 2009-10-16T13:20:09 Correct the signatures for the evmap_io_* functions to use evutil_socket_t. svn:r1446
Nick Mathewson ba8a1771 2009-10-02T03:03:58 Do not notify the main thread more than needed. Basically, we suppress the notification when an event is added or deleted and: - The event has no fd, or there is no change in whether we are reading/writing on the event's fd. - The event has no timeout, or adding the event did not make the earliest timeout become earlier. This should be a big efficiency win in applications with multiple threads and lots of timeouts. svn:r1439
Nick Mathewson c2ead9f1 2009-09-11T21:02:19 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
Nick Mathewson 5b5b880b 2009-07-28T19:41:39 Various MSVC cleanups from Brodie Thiesfield. svn:r1385
Nick Mathewson 64a37e61 2009-04-17T06:56:36 Fix evmap indentation to be less stupid. svn:r1185
Nick Mathewson b85b710c 2009-01-27T22:34:36 Update copyright statements to reflect the facts that: a) this is 2009 b) niels and nick have been comaintainers for a while c) saying "all rights reserved" when you then go on to explicitly disclaim some rights is sheer cargo-cultism. svn:r1065
Nick Mathewson 8889a770 2009-01-27T22:30:46 Replace all use of config.h with event-config.h. svn:r1064
Niels Provos 0e779906 2009-01-26T06:13:24 fix memleak in evmap_signal_clear; from Alexander Drozdov svn:r1049
Nick Mathewson 554e1493 2009-01-14T20:52:32 Move per-fd info from eventops into evmap. Not done for win32.c yet. svn:r1008
Nick Mathewson ad7f1b4a 2009-01-14T18:45:42 The element size for our linear evmaps is a pointer, not the whole struct. svn:r1006
Nick Mathewson 6bb2f842 2009-01-14T18:38:03 Add initializer functions for evmap types. svn:r1005
Nick Mathewson 9935d5b0 2009-01-13T21:39:32 Fix win32 compilation. Surprisingly, unit tests pass too. svn:r1002
Nick Mathewson 169321c9 2009-01-13T20:26:37 Rename four internal headers to follow the -internal.h convention. svn:r1000
Nick Mathewson 91e3ead8 2009-01-10T14:37:45 Improve the hashsocket function. svn:r989
Nick Mathewson 55bcd7d2 2009-01-09T13:42:21 On win32, use a hashtable to map sockets to events rather than using an array. svn:r988
Nick Mathewson 8f5777e6 2009-01-09T05:01:48 Document internal evmap functions, add a couple of asserts, and fix up some things that did not need to be void* any more svn:r987
Niels Provos 172b6575 2009-01-02T18:18:30 malloc fd only if it is needed. svn:r982
Niels Provos 30cba6d0 2008-12-25T09:22:13 we cannot realloc memory used by TAILQ; instead malloc each slot individually svn:r977
Niels Provos b55ca7de 2008-12-23T22:31:27 reduce void *age a little bit svn:r975
Niels Provos 02b2b4d1 2008-12-23T16:37:01 Restructure the event backends so that they do not need to keep track of events themselves, as a side effect multiple events can use the same fd or signal. svn:r972