event-internal.h


Log

Author Commit Date CI Message
Nick Mathewson 5b18f130 2011-08-24T16:17:05 Make rate limiting work with common_timeout logic
Nick Mathewson e7fe9270 2011-07-04T12:16:08 Merge remote-tracking branch 'github/20_global_locks_init' into patches-2.0
Nick Mathewson e9340964 2011-06-22T11:22:35 Fix AIX build issue with TAILQ_FOREACH definition Reported by Lawnstein Chan.
Nick Mathewson b683cae3 2011-04-22T12:01:25 Avoid race-condition when initializing global locks Previously, we did stuff like if (!lock) EVTHREAD_ALLOC_LOCK(lock,0); for the evsig base global lock, the arc4random lock, and the debug_map lock. But that's potentially racy! Instead, we move the responisiblity for global lock initialization to the functions where we set up the lock callbacks. (Rationale: We already require that you set up the locking callbacks before you create any event_base, and that you do so exatly once.)
Nick Mathewson a459ef70 2011-03-03T15:34:22 Have event_base_gettimeofday_cached() always return wall-clock time Based on code by Dave Hart
Kevin Bowling c4dc3353 2010-11-23T00:22:01 Add some checks since lack of TAILQ_FOREACH doesn't imply lack of FIRST, END, NEXT, or INSERT_BEFORE. Quiet some warnings in XL C.
Dimitre Piskyulev f817bfa4 2010-10-27T17:31:52 Fix some ints to evutil_socket_t; make tests pass on win64.
Nick Mathewson 38d09606 2010-09-15T12:50:31 Remove event_base.evsigbase; nothing used it.
Nick Mathewson 3658b169 2010-09-08T14:12:12 Merge remote branch 'chrisd/iocp-fixes4' Conflicts: test/regress_thread.c
Nick Mathewson 4632b78e 2010-09-08T13:22:55 Minimize calls to base_notify implementation functions, thereby avoiding needless syscalls The trick here is that if we already told the base to wake up, and it hasn't woken up yet, we don't need to tell it to wake up again. This should help lots with inherently multithreaded code like IOCP.
Christopher Davis 2447fe88 2010-08-28T04:07:48 Add event_config_set_num_cpus_hint for tuning thread pools, etc.
Christopher Davis 76f7e7ae 2010-08-17T05:02:00 Some IOCP bufferevent tweaks. - Increment reference count of bufferevents before initiating overlapped operations to prevent the destructor from being called while operations are pending. The only portable way of canceling overlapped ops is to close the socket. - Translate error codes to WSA* codes. - Better handling of errors. - Add an interface to add and del "virtual" events. Because IOCP bufferevents don't register any events with the base, the event loop has no way of knowing they exist. This causes the loop to terminate prematurely. event_base_{add,del}_virtual increment/decrement base's event count so the loop runs while there are any enabled IOCP bufferevents.
Nick Mathewson e0972c21 2010-08-17T13:18:18 Use conditions instead of current_event_lock to fix a deadlock. Avi Bab correctly noted as bug 3044479 the fact that any thread blocking on current_event_lock will do so while holding th_base_lock, making it impossible for the currently running event's callback to call any other functions that require th_base_lock. This patch switches the current_event_lock code to instead use a condition variable that we wait on if we're trying to mess with a currently-executing event, and that we signal when we're done executing a callback if anybody is waiting on it.
Gilad Benjamini 60433a0a 2010-08-13T17:08:59 Clean up syntax on TAILQ_ENTRY() usage Though the C standards allow it, it's apparently possible to get MSVC upset by saying "struct { int field; } (declarator);" instead of "struct {int field; } declarator;", so let's just not do that. Bugfix for 3044492 (commit msg by nickm)
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 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 b557b175 2010-03-21T13:28:48 Detect and refuse reentrant event_base_loop() calls Calling event_base_loop on a base from inside a callback invoked by that same base, or from two threads at once, has long been a way to get exceedingly hard-to-diagnose errors. This patch adds code to detect such reentrant invocatinos, and exit quickly with a warning that should explain what went wrong.
Nick Mathewson cdd4c490 2010-03-11T00:38:46 Try to comment some of the event code more
Nick Mathewson 17efc1cd 2010-03-04T01:25:51 Update all our copyright notices to say "2010"
Nick Mathewson 23170a69 2010-02-25T16:57:57 Fix mingw compilation
Nick Mathewson 4faeaea9 2010-02-19T03:39:50 Clean up formatting: function/keyword spacing consistency. - Keywords always have a space before a paren. Functions never do. - No more than 3 blank lines in a row.
Nick Mathewson e5bbd40a 2010-02-18T17:41:15 Clean up formatting: use tabs, not 8-spaces, to indent.
Nick Mathewson a66e947b 2010-01-25T13:44:56 Use less memory for each entry in a hashtable Our hash-table implementation stored a copy of the hash code in each element. But as we were using it, all of our hash codes were ridiculously easy to calculate: most of them were just a matter of a load and a shift. This patch lets ht-internal be built in either of two ways: one caches the hash-code for each element, and one recalculates it each time it's needed. This patch also chooses a slightly better hash code for event_debug_entry.
Nick Mathewson cd17c3ac 2010-01-22T00:34:37 Add support for a "debug mode" to try to catch common errors. Right now it only catches cases where we aren't initializing events, or where we are re-initializing events without deleting them first. These are however shockingly common.
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 74871cac 2009-11-09T19:37:27 Change event_base.activequeues to "array of eventlist". Previously, event_base.activequeues was of type "array of pointers to eventlist." This was pointless: none of the eventlists were allowed to be NULL. Worse, it was inefficient: - It made looking up an active event queue take two pointer deferences instead of one, thus risking extra cache misses. - It used more RAM than it needed to, because of the extra pointer and the malloc overhead. Also, this patch fixes a bug where we were saying calloc(N,N*sizeof(X)) instead of calloc(N,sizeof(X)) when allocating activequeues. That part, I'll backport. Also, we warn and return -1 on failure to allocate activequeues, rather than calling event_err. svn:r1525
Nick Mathewson ab96b5f3 2009-11-09T18:30:33 Add an option to disable the timeval cache. svn:r1518
Nick Mathewson 693c24ef 2009-11-09T17:16:30 Implement queued timeouts for case where many timeouts are the same. Libevent's current timeout code is relatively optimized for the randomly scattered timeout case, where events are added with their timeouts in no particular order. We add and remove timeouts with O(lg n) behavior. Frequently, however, an application will want to have many timeouts of the same value. For example, we might have 1000 bufferevents, each with a 2 second timeout on reading or writing. If we knew this were always the case, we could just put timeouts in a queue and get O(1) add and remove behavior. Of course, a queue would give O(n) performance for a scattered timeout pattern, so we don't want to just switch the implementation. This patch gives the user the ability to explicitly tag certain timeout values as being "very common". These timeout values have a cookie encoded in the high bits of their tv_usec field to indicate which queue they belong on. The queues themselves are each triggered by an entry in the minheap. See the regress_main.c code for an example use. svn:r1517
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 b06b2649 2009-07-26T01:29:39 Make "deferred callback queue" independent of event_base. This way, we can more easily have an IOCP bufferevent implementation that does not need an event_base at all. Woot. svn:r1381
Nick Mathewson 5d71b25b 2009-07-17T18:38:38 Remove all trailing whitespace from end-of-line. svn:r1350
Nick Mathewson 6b4b77a2 2009-07-14T16:54:48 Make event_del(E) block while E is running in another thread. This gives you the property that once you have called event_del(E), you know that E is no longer running or pending or active at all, and so it is safe to delete the resource used by E's callback. svn:r1341
Nick Mathewson b4886ec8 2009-05-15T18:44:44 Trim 22 bytes from struct event on 32 bit platforms, more on 64-bit platforms. svn:r1292
Nick Mathewson fe47003d 2009-05-05T16:52:37 Make unit tests for bufferevent_async compile and _almost_ work. Either I need to make the callbacks get deferred in a base with no events (doable), or I need to make it okay to call launch_read from inside the callback for read (tricky). svn:r1277
Nick Mathewson b69d03b5 2009-05-05T14:18:14 Add a constructor for bufferevent_async. svn:r1274
Nick Mathewson 838d0a81 2009-04-17T06:55:08 Document many internal functions and pieces of code. svn:r1181
Nick Mathewson 4868f4d2 2009-04-10T14:22:33 Initial support for a lightweight 'deferred callbacks'. A 'deferred callback' is just a function that we've queued in the event base. This ability is needed for some mt stuff, and for complex callback chains. For internal use only. svn:r1150
Nick Mathewson ec35eb55 2009-02-12T22:19:54 Make threading functions global, like the mm_ functions. Use the libevent_pthread.la library in regress_pthread. svn:r1121
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 56ea4687 2009-01-22T02:33:38 Change the semantics of timeouts in conjunction with EV_PERSIST; timeouts in that case will now repeat until deleted. svn:r1032
Nick Mathewson a5901991 2009-01-19T20:37:24 Use eventfd for main-thread notification where available (i.e., linux). svn:r1023
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 169321c9 2009-01-13T20:26:37 Rename four internal headers to follow the -internal.h convention. svn:r1000
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
Niels Provos 30cba6d0 2008-12-25T09:22:13 we cannot realloc memory used by TAILQ; instead malloc each slot individually svn:r977
Niels Provos d776f846 2008-12-23T22:23:37 deprecate the usage of signal_{add,del,set} and name it evsignal_{add,del,set} instead; move the old definitions to compat svn:r973
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
Niels Provos f7e61870 2008-07-11T15:49:04 support multiple events listening on the same signal; make signals regular events that go on the same event queue svn:r901
Nick Mathewson 05965921 2008-05-31T14:37:31 Add new functions to access backends by their features and to query the features of a backend. svn:r842
Niels Provos 3f56e364 2008-05-08T05:56:20 event_base_new_with_config() and related methods svn:r789
Niels Provos 8c750eaf 2008-05-03T21:37:33 separate signal events from io events svn:r760
Niels Provos 45e6fb0d 2008-05-03T18:23:44 cache clock_gettime/gettimeofday values in base svn:r758
Niels Provos c182baca 2008-03-10T03:17:20 switch thread support so that locks get allocated as they are needed. svn:r690
Niels Provos 558de9b3 2008-03-02T21:18:33 Provide OpenSSL style support for multiple threads accessing the same event_base svn:r684
Niels Provos 03589ccb 2007-12-24T22:49:30 rollback r594: restructuring to make event activation independent. changes are going to wait for api design svn:r612
Niels Provos 7aa845b7 2007-12-16T04:10:30 restructure the code to make event activation independent of regular event logic svn:r594
Niels Provos fbe24f43 2007-12-09T05:07:20 remove obsoleted recalc code svn:r581
Nick Mathewson 2823cb05 2007-11-25T17:15:28 r14944@tombo: nickm | 2007-11-25 12:12:28 -0500 Make kqueue pass more unit tests. svn:r544
Nick Mathewson 7eb250e9 2007-11-25T17:14:19 r14939@tombo: nickm | 2007-11-25 11:59:26 -0500 New function event_set_mem_functions to replace internal calls to malloc, free, etc with a user-supplied functions. svn:r541
Niels Provos 88897852 2007-11-25T06:57:59 provide event_reinit() to reinitialized an event_base after fork - necessary for epoll/kqueue svn:r539
Nick Mathewson 1c23e219 2007-11-17T22:21:42 r14931@tombo: nickm | 2007-11-17 17:21:09 -0500 Patch from Scott Lamb: Implement event_{base_}loopbreak. Includes documentation and tests. From sf.net Feature Request 1826546. svn:r535
Nick Mathewson f74e7258 2007-11-07T06:01:57 r16501@catbus: nickm | 2007-11-07 01:00:31 -0500 This is one of those patches which will either make matters far simpler after the bugs shake out, or will get reverted pretty quick once we realize that it is a stupid idea. We now post-process the config.h file into a new event-config.h file, whose macros are prefixed with _EVENT_ and which is thus safe for headers to include. Using this, we can define replacement timeval manipulation functions in evutil.h, and use them uniformly through our code. We can also detect which headers are needful in event.h, and include them as required. This is also the perfect time to remove the long-deprecated acconfig.h file, so that autoheader no longer warns. Should resolve the following issues: [ 1826530 ] Header files should have access to autoconf output. [ 1826545 ] acconfig.h is deprecated. [ 1826564 ] On some platforms, event.h can't be included alone. svn:r492
Niels Provos 30ae40cc 2007-11-03T18:04:53 switch timeouts to a min heap; from Maxim Yegorushkin svn:r467
Niels Provos 41b7cbc3 2007-03-10T06:37:53 more the signal base into the event base; this removes global state and makes signals work better with threading; from Wouter Wijngaards small fixes for kqueue and style by me svn:r351
Niels Provos 905ee67d 2005-02-22T15:47:53 provide maintainer mode in automake; put event_gotsig back into global state; return proper error code svn:r131
Niels Provos 8773c4c9 2004-11-25T09:50:18 make libevent thread-safe; first cut svn:r122