kc3-lang/libevent/event.c

Branch :


Log

Author Commit Date CI Message
66ee086b 2024-05-06 23:32:00 Fix conversion loses precision ssize_t to int in evthread_notify_base_default()
7afbdcf2 2024-05-06 23:31:27 Ensure that event had been removed in event_process_active_single_queue() It should not be possible, since only EVLIST_ACTIVE should be triggered from event_process_active_single_queue, but adding assert will not hurt.
a41453ab 2024-05-09 17:34:15 Eliminate the redundant ev_uint64_t for eventfd --------- Signed-off-by: Andy Pan <i@andypan.me>
0428771a 2024-05-01 23:17:54 Remove redundant condition in function:event_base_once
6074d558 2024-04-17 10:36:47 Avoid calling read(2) on eventfd on each event-loop wakeup Register the eventfd with EPOLLET to enable edge-triggered notification where we don't need to read the data from the eventfd for every wakeup event. When the eventfd counter reaches the maximum value of the unsigned 64-bit, we rewind the counter and retry again. This optimization saves one system call on each event-loop wakeup, which eliminates the extra latency for epoll as the EVFILT_USER filter does for the kqueue.
2e312772 2023-06-20 22:18:41 Disable lazy gettimeofday/clock_gettime comparison The benefit of this optimization is questionable for the following reasons: - libevent uses CLOCK_MONOTONIC_COARSE which is fast enough (on my desktop CLOCK_MONOTONIC/CLOCK_MONOTONIC_RAW works 40/50 millions of ops per second, and CLOCK_MONOTONIC_COARSE is faster) - libevent has caching of time (EVENT_BASE_FLAG_NO_CACHE_TIME) So I don't see any reason for using one more caching - lazy comparsion (whatever you call it).
4f993028 2023-06-13 07:23:10 Synchronize clock before tv_timeout calculation.
d1969098 2022-12-09 13:09:44 Silence weird GCC warning about an uninitialized variable For the CMake release build with -DEVENT__ENABLE_GCC_WARNINGS=ON and -DEVENT__DISABLE_MM_REPLACEMENT=ON, GCC version 11 and 12 may complain about possibly uninitialized variable: In function ‘event_debug_assert_not_added_’, inlined from ‘event_assign’ at event.c:2184:2, inlined from ‘event_new’ at event.c:2276:6: cc1: error: ‘ev’ may be used uninitialized [-Werror=maybe-uninitialized] event.c: In function ‘event_new’: event.c:361:13: note: by argument 1 of type ‘const struct event *’ to event_debug_assert_not_added_.part.0’ declared here 361 | static void event_debug_assert_not_added_(const struct event *ev) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This warning is most likely a false positive and can be silenced by explicitly disabling inlining for 'event_assign()'. Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
d06e573c 2023-05-05 15:13:05 style fix: use tab for indent
1af745d0 2022-10-25 11:30:34 signal: new signal handling backend based on signalfd Linux-specific signal handling backend based on signalfd(2) system call, and public function event_base_get_signal_method() to obtain an underlying kernel signal handling mechanism. Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
2dfad6c3 2022-11-12 18:06:09 Suppress -Wdangling-pointer in event_signal_closure() gcc 12 complains: [34/46] Building C object CMakeFiles/event_static.dir/event.c.o /src/le/libevent/event.c: In function ‘event_signal_closure’: /src/le/libevent/event.c:1384:32: warning: storing the address of local variable ‘ncalls’ in ‘*ev.ev_.ev_signal.ev_pncalls’ [-Wdangling-pointer=] 1384 | ev->ev_pncalls = &ncalls; | ~~~~~~~~~~~~~~~^~~~~~~~~ /src/le/libevent/event.c:1378:15: note: ‘ncalls’ declared here 1378 | short ncalls; | ^~~~~~ /src/le/libevent/event.c:1378:15: note: ‘ev’ declared here
b19af675 2022-08-28 15:27:04 Fix non-std printf %p arguments (#1327) * Fix non-std printf %p arguments when running with -Werror -pedantic-errors Co-authored-by: Mareks Malnacs <mareks.malnacs>
990bcfc2 2021-09-06 08:06:10 ev_io_timeout consistency
74594077 2021-09-05 22:42:04 modify typo - timeeouts
83ef3216 2020-04-22 19:44:45 Add wepoll support to light up the epoll backend on Windows libevent is lacking a scalable backend on Windows. Let's leverage the wepoll library until Windows comes up with an epoll/kqueue compete user mode API. - All regress tests pass for standard wepoll - These 2 tests fail intermittently for changelist wepoll, so disabling changelist wepoll for now http/cancel_inactive_server http/stream_in - verify target on Windows runs tests for both wepoll and win32 backends - wepoll backend preferred over win32 backend - wepoll version 1.5.6 v2: cleaner backend abstraction. Disallow wepoll on MinGW/Cygwin. v3: Add wepoll.h to dist v4: Make sure wepoll source files are excluded from cygwin/mingw builds v5: Keep win32 as default backend on windows. v6: Include wepoll in mingw builds. Verified that regress tests pass w/ WEPOLL backend. v7: Enable wepoll on mingw when building with cmake v8: Add wepoll testrunner for autotools test target
968bbd5c 2020-02-04 16:05:02 event_base_once: fix potential null pointer threat supposing if base is null, EVBASE_ACQUIRE_LOCK and EVBASE_RELEASE_LOCK would get a coredump, so we add a guard for protection. Signed-off-by: chenguolong <cgl.chenguolong@huawei.com>
ddacaef5 2019-08-29 22:57:44 Revert "Warn if forked from the event loop during event_reinit()" Thinking about this more and realizing that this was a mistake, so should be reverted. In a nut shell I guess most of the apps calls event_reinit() from the loop (see [1] for example), and this should be totally fine (the bit with the signals [2] handled in event_reinit() gracefully) [1]: https://archives.seul.org/libevent/users/Aug-2019/msg00009.html [2]: https://github.com/libevent/libevent/pull/833#issuecomment-501834453 This reverts commit 497ef904d544ac51de43934549dbeccce8e6e8f8. Reported-by: mikulas@twibright.com Backport-to: 2.1
445027a5 2019-08-22 16:36:12 Fix memory corruption in EV_CLOSURE_EVENT_FINALIZE with debug enabled Call event_debug_note_teardown_ before evcb_evfinalize to avoid possible UAF (if finalizer free's event).
497ef904 2019-07-01 23:54:02 Warn if forked from the event loop during event_reinit() Calling fork() from the event loop is not a great idea, since at least it shares some internal pipes (for handling signals) before event_reinit() call Closes: #833
176fd566 2019-04-16 21:12:21 Protect min_heap_push_ against integer overflow. Converting unsigned to size_t for size of memory objects allows proper handling of very large heaps on 64 bit systems. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org> Closes: #799 (cherry-picked)
1cd8830d 2019-04-17 15:44:59 evwatch: fix race condition There was a race between event_base_loop and evwatch_new (adding a prepare/check watcher while iterating over the watcher list). Only release the mutex immediately before invoking each watcher callback, and reacquire it immediately afterwards (same as is done for normal event handlers).
2f184f8b 2019-03-26 13:33:57 evwatch: Add "prepare" and "check" watchers. Adds two new callbacks: "prepare" watchers, which fire immediately before we poll for I/O, and "check" watchers, which fire immediately after we finish polling and before we process events. This allows other event loops to be embedded into libevent's, and enables certain performance monitoring. Closes: #710
62df1301 2014-12-09 21:43:18 Add support for EV_TIMEOUT to event_base_active_by_fd Closes: #194 (cherry-pick)
9d3a415a 2018-12-09 14:48:44 Do not check O_NONBLOCK for invalid fds Fixes: 6f988ee1 ("Merge branch 'check-O_NONBLOCK-in-debug'")
f2da6198 2018-11-13 08:24:55 event: add some debug information into loop for event_base_free_queues_() Refs: 7c8d0152dda18ecc52d3099fea235b04ddb850d9 ("Free event queues even for recursive finalizers")
965ed54c 2014-01-08 14:57:14 assert that fds are nonblocking in debug mode Check that each fd that had been added with some event do has O_NOBLOCK after event_enable_debug_mode() Rebased and do not check signals (EV_SIGNAL) by azat. Refs: nmathewson/Libevent#90 Refs: #96
aa07cbac 2018-10-29 22:22:00 Add ET flag into event_base_dump_events()
23c2914f 2018-04-24 00:59:11 Notify event base if there are no more events, so it can exit without delay Fixes: #623
08a0d366 2018-02-27 21:12:14 Fix base unlocking in event_del() if event_base_set() runned in another thread Image next situation: T1: T2: event_del_() lock the event.ev_base.th_base_lock event_del_nolock_() event_set_base() unlock the event.ev_base.th_base_lock In this case we will unlock the wrong base after event_del_nolock_() returns, and deadlock is likely to happens, since event_base_set() do not check any mutexes (due to it is possible to do this only if event is not inserted anywhere). So event_del_() has to cache the base before removing the event, and cached base.th_base_lock after.
f0fd92f2 2018-02-27 21:08:35 Convert event_debug_*() helpers from macros to static functions
6cce7458 2017-12-09 14:39:07 If precise_time is false, we should not set EVENT_BASE_FLAG_PRECISE_TIMER Fixes: 630f077c296de61c7b99ed83bf30de11e75e2740 ("Simple unit tests for monotonic timers")
27934f0b 2017-08-07 11:06:28 Fix race in access to ev_res from event loop with event_active() Detected using ThreadSanitizer, resolved by capturing the value of ev_res in a local variable while the event is locked, then passing that captured variable to the callback. TSAN report: I0728 14:35:09.822118 WARNING: ThreadSanitizer: data race (pid=815501) I0728 14:35:09.822186 Write of size 2 at 0x7b2c00001bf2 by thread T80 (mutexes: write M1110835549570434736): I0728 14:35:09.822248 #0 event_active_nolock_ libevent/event.c:2893:14 (0a2b90577e830d775300664df77d0b91+0x1fdab28) I0728 14:35:09.822316 #1 event_active libevent/event.c:2858:2 (0a2b90577e830d775300664df77d0b91+0x1fdd10e) I0728 14:35:09.822379 #2 Envoy::Event::TimerImpl::enableTimer(std::chrono::duration<long, std::ratio<1l, 1000l> > const&) envoy/source/common/event/timer_impl.cc:24:5 (0a2b90577e830d775300664df77d0b91+0x459fa0) ... I0728 14:35:09.824146 Previous read of size 2 at 0x7b2c00001bf2 by main thread: I0728 14:35:09.824232 #0 event_process_active_single_queue libevent/event.c:1646:33 (0a2b90577e830d775300664df77d0b91+0x1fdf83d) I0728 14:35:09.824350 #1 event_process_active libevent/event.c (0a2b90577e830d775300664df77d0b91+0x1fd9ad8) I0728 14:35:09.824445 #2 event_base_loop libevent/event.c:1961 (0a2b90577e830d775300664df77d0b91+0x1fd9ad8) I0728 14:35:09.824550 #3 Envoy::Event::DispatcherImpl::run(Envoy::Event::Dispatcher::RunType) envoy/source/common/event/dispatcher_impl.cc:166:3 (0a2b90577e830d775300664df77d0b91+0x4576d9) ... Fixes: #543 (pull-request)
0b4b0efd 2015-04-13 08:54:52 Return from event_del() after the last event callback termination Delete the event from the queue before blocking for the current event callback termination. Ensures that no callback is being executed when event_del() returns, hence making this function a secure mechanism to access data which is handled in the event callack. Fixes: #236 Fixes: #225 Refs: 6b4b77a Fixes: del_wait
177e2171 2017-03-24 16:49:59 Make event_count macros cleaner Fixes: #489
9081b66c 2017-03-12 20:50:35 Export symbols for -fvisibility=hidden (under cmake) Fixes: #442
94e7dceb 2017-01-29 17:23:14 Fix -Werror=implicit-fallthrough (fixes gcc-7) Fixes: #447
88640aa1 2015-12-27 02:15:03 event_reinit: make signals works after fork() without evsig_add() event_reinit() removes the event, but only evsig_add puts it back. So any signals set up before event_reinit will be ignored until another signal is added. Fixes: #307
ad0c237b 2015-12-27 01:43:37 event_reinit: always re-init signal's socketpair Before this patch event_reinit() only closes the signal socketpair fds and recreates them if signals have been added, but this is wrong, since socketpair fds created on backend init, and if we will not re-create them bad things in child/parent signal handling will happens (and indeed this is what happens for non-reinit backends like select). Fixes: #307
7c8d0152 2015-10-30 13:34:30 Free event queues even for recursive finalizers For finalizers we can register yet another finalizer out from finalizer, and iff finalizer will be in active_later_queue we can add finalizer to activequeues, and we will have events in activequeues after event_base_free() returns, which is not what we want (we even have an assertion for this). A simple case is bufferevent with underlying (i.e. filters) in inactive queue. Fixes: regress bufferevent/bufferevent_socket_filter_inactive
f337296a 2015-10-04 03:35:43 Fix checking for make_base_notifiable() Fixes: a068f2e5 ("event_debug_created_threadable_ctx_: fix compilation without debug mode") Found-after: 3e56da23 ("travis: add builds without debug mode into matrix")
a068f2e5 2015-09-29 20:36:39 event_debug_created_threadable_ctx_: fix compilation without debug mode The following command failed before: $ ./configure --disable-debug-mode Fixes: dcfb19a27b7760299bc9e7291c9abd88c59fd91a ("Debug mode option to error on evthread init AFTER other event calls.")
dcfb19a2 2015-05-15 02:58:14 Debug mode option to error on evthread init AFTER other event calls. - A handy event_enable_debug_mode() feature which will error and abort the application if any thread-aware libevent functions are called BEFORE the evthread API has been initialized (manually, or through evthread_use_windows_threads() / evthread_use_pthreads() - This is done by setting the global debug variable 'event_debug_created_threadable_ctx_' whenever the following functions are called: evthreadimpl_lock_alloc_() evthreadimpl_cond_alloc_() event_base_new_with_config() <- this checks to see if the thread callbacks are enabled first, so we have to manually set the variable. - Example: int main(int argc, char ** argv) { struct event_base * base; event_enable_debug_mode(); base = event_base_new(); evthread_use_pthreads(); return 0; } When executed, the program will throw an error and exit: [err] evthread initialization must be called BEFORE anything else!
6e7a580c 2015-03-24 17:45:52 tab
38cef641 2015-03-24 17:29:40 fix the return value of event_deferred_cb_schedule_
a77a82a0 2015-02-04 08:37:32 Merge remote-tracking branch 'azat/be-pair-fix-freeing-shared-lock-v5'
e5c87d18 2015-01-26 00:29:15 event_free_debug_globals_locks(): disable lock debugging This will allow to use library event after event_free_debug_globals_locks()/libevent_global_shutdown() without invalid read/write's.
941faaed 2015-01-08 04:45:27 event: call event_disable_debug_mode() in libevent_global_shutdown() This will avoid leaking of event_debug_map_HT_GROW I buildin it into libevent_glboal_shutdown() because event_disable_debug_mode() -> event_free_debug_globals() -> event_free_debug_globals_locks() will clean event_debug_map_lock_ that used in event_disable_debug_mode().
f2645f80 2014-11-19 12:18:05 Implement new/free for struct evutil_monotonic_timer and export monotonic time functions
37145c56 2014-11-30 21:07:55 Merge remote-tracking branch 'public/patches-2.0' Conflicts: ChangeLog event.c
3c7d6fca 2014-09-22 12:19:37 Fix race caused by event_active There is a race between manual event_active and natural event activation. If both happen at the same time on the same FD, they would both be protected by the same event base lock except for 1 LoC where the fields of struct event are read without any kind of lock. This commit does those reads into local variables inside the lock and then invokes the callback with those local arguments outside the lock. In 2.0-stable, none of this is inside the lock; in HEAD, only the callback is read inside the lock. This gets the callback and all 3 arguments inside the lock before calling it outside the lock.
3cc0eace 2014-09-16 22:25:52 Fix use-after-free error in EV_CLOSURE_EVENT callback
ec99dd82 2014-03-18 11:25:58 Fix a use-after-free error on EV_CLOSURE_EVENT_FINALIZE callbacks After running the callback, we were checking evcb->evcb_closure to decide whether to call mm_free(ev). But the callback itself might have freed ev, so we need to grab that field first Found with AddressSanitizer
98059721 2014-03-06 10:09:03 Move assert(ev) to before we use ev in EV_CLOSURE_EVENT_FINALIZE case Based on a patch from Harlan Stenn.
2ea15ed0 2014-01-27 14:54:55 Tweaked callbacks to prevent race condition (https://github.com/libevent/libevent/issues/104)
40830f16 2014-01-27 13:03:36 Tweaked callbacks to prevent race condition (https://github.com/libevent/libevent/issues/104)
b1b69ac7 2014-01-17 23:20:42 Implemented EV_CLOSED event for epoll backend (EPOLLRDHUP). - Added new EV_CLOSED event - detects premature connection close by clients without the necessity of reading all the pending data. Does not depend on EV_READ and/or EV_WRITE. - Added new EV_FEATURE_EARLY_CLOSED feature for epoll. Must be supported for listening to EV_CLOSED event. - Added new regression test: test-closed.c - All regression tests passed (test/regress and test/test.sh) - strace output of test-closed using EV_CLOSED: socketpair(PF_LOCAL, SOCK_STREAM, 0, [6, 7]) = 0 sendto(6, "test string\0", 12, 0, NULL, 0) = 12 shutdown(6, SHUT_WR) = 0 epoll_ctl(3, EPOLL_CTL_ADD, 7, {EPOLLRDHUP, {u32=7, u64=7}}) = 0 epoll_wait(3, {{EPOLLRDHUP, {u32=7, u64=7}}}, 32, 3000) = 1 epoll_ctl(3, EPOLL_CTL_MOD, 7, {EPOLLRDHUP, {u32=7, u64=7}}) = 0 fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 4), ...}) mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYM... write(1, "closed_cb: detected connection close "..., 45) = 45
f9e091bf 2014-01-06 12:11:30 Merge remote-tracking branch 'asweeny86/event-count-max'
efbd3dcf 2014-01-05 16:29:52 Fixed bug using wrong variable in max event compare
5173bef5 2013-12-30 14:06:20 Add access to max event count stats This commit provides an interface for accessing and resetting the maximum number of events in a given period. This information provides better insight into event queue pressure.
87fa2b00 2013-12-23 20:46:38 Unit tests for active_by_fd; unsupport active_by_fd(TIMEOUT) [It turns out that event_base_active_by_fd(TIMEOUT) didn't actually work right. Feel free to add it back in as a patch.]
48659433 2013-12-21 23:32:10 Add event_base_active_by_signal by analogy
5c9da9a8 2013-12-21 23:21:33 Sanity-check arguments to event_base_active_by_fd()
93369ff4 2013-12-21 23:15:41 Merge remote-tracking branch 'ghazel/event_base_active_by_fd'
1c06985a 2013-08-06 20:00:53 Add an assertion for another of the complaints from coverity. See 1b065d07df196
69b5c647 2013-08-06 19:08:42 Move event_debug_note_teardown_ before mm_free. This isn't a bug, since only the pointer value of ev was used, but it's probably best not to tempt fate. Found by coverity.
1b065d07 2013-08-06 19:06:58 Add some assertions to please coverity. In event_process_active_single_queue, EVLIST_INIT must be set on any event that uses one of the event-only closures, and so "ev" will be set in those cases. But coverity's worried here (CIDs numerous). So instead, just add the assertions that should make it happy.
0fa107d8 2013-07-02 16:01:02 Added event_base_get_num_events()
3dc2d8ab 2013-05-28 10:14:51 Remove a debugging assert that should not have been left in
d3d999a1 2013-05-10 20:22:56 Missed lock acquire/release in event_base_cancel_single_callback_() Call backtrace: ... event_queue_remove_active() event_callback_cancel_nolock_() event_base_cancel_single_callback_() event_base_free_() event_base_free() ... Fix for e9ebef83
f2925d78 2013-04-30 22:57:25 Fix a windows compilation regression This is github issue #57; reported by "efekty". I assume the compiler is MSVC.
3555befd 2013-04-26 12:27:05 Merge branch '21_deadlock_fix_v2'
5d11f4f3 2013-04-26 11:57:40 Make the event_finalize* functions return an error code
a800b913 2013-04-26 11:36:43 More documentation for finalization feature
e9ebef83 2013-04-09 21:14:52 Always run pending finalizers when event_base_free() is called There was actually a bug in the original version of this: it tried to run the finalizers after (potentially) setting current_base to NULL; but those finalizers could themselves (potentially) be invoking stuff that needed to know about the current event_base. So the right time to do it is _before_ clearing current_base.
8eedeabe 2013-03-28 14:13:19 Implement event_finalize() and related functions to avoid certain deadlocks
5e6fa2a3 2013-04-24 13:23:15 event_base_update_cache_time should be a no-op if the loop isn't running
9443868d 2013-03-05 11:29:33 Double-check next timeout when adding events When resuming the system from a suspended state, the ev_timeout field of a scheduled timer event may be in the past. This leads to unexpected behavior when scheduling a short-duration timer event immediately after returning from suspension, because the new event does not land on top of the timeout minheap and so the event loop (blocked on a possibly long-duration timeout) is not notified. This patch checks for this condition and, if it obtains, notifies the event loop.
0c6ec5d8 2013-02-07 17:20:08 use FormatMessage for winsock errors as discussed here: http://archives.seul.org/libevent/users/Feb-2013/msg00004.html
5623e803 2013-02-12 15:10:50 Make event_remove_timer behave correctly with persistent timers
865a1426 2013-01-16 16:31:08 event_base_active_by_fd
bf7a0ff2 2013-01-11 16:37:34 When EWOULDBLOCK is not EAGAIN, treat it as equivalent to it Acording to http://stackoverflow.com/questions/7003234/which-systems-define-eagain-and-ewouldblock-as-different-values there are some older unixes that distinguish these error.s
f2703b2e 2012-11-18 01:40:13 Fix a warning when building without threading.
e3b2e086 2012-11-16 16:15:03 Add an event_remove_timer() to remove timer on an event without deleting it
1fda4928 2012-11-16 12:06:40 Merge remote-tracking branch 'origin/patches-2.0'
e3cccf38 2012-11-16 11:55:27 Avoid crash when event_pending() called with no event_base set on event Instead, give a warning and return 0. Reported by Antony Dovgal on github as https://github.com/libevent/libevent/issues/19
c17dd591 2011-07-15 11:10:54 Free dangling event_once objects on event_base_free() This patch makes us keep event_once objects in a doubly linked list so we can free any once that haven't triggered when we call event_base_free().
56e48c10 2012-11-02 10:58:02 Fix a few mingw64 incompatibilities introduced since 2.0
2e6a9850 2012-11-01 18:12:07 Merge remote-tracking branch 'github/20_win64_compilation' into 21_win64_compilation Conflicts: event.c http.c sample/event-read-fifo.c test/regress_bufferevent.c
94866c27 2012-11-01 17:38:34 Compile without warnings on mingw64 This is mostly a matter of catching cases where we were still assuming that evutil_socket_t could be used as an int.
ffe1643b 2012-09-10 13:43:26 Add missing return value in event_base_foreach_event Fix for github issue nmathewson/Libevent #65 Found by Joachim Bauch
232055ef 2012-09-07 09:58:24 Tweak patch for event_base_foreach_event() * Fix whitespace * Explain return value from callback function * Reinstate return value so that caller can tell whether forech exited early. * Rename event_base_foreach_event_() to event_base_foreach_event_nolock_(). * Use event_base_foreach_event_cb_fn typedef in more places * Be more dire about undefined behavior.
84fd6d75 2012-09-07 09:47:50 Expose event_base_foreach_event() as a public API.
6c14d564 2012-07-16 15:44:07 Merge remote-tracking branch 'origin/patches-2.0' Conflicts: event.c win32select.c
9cd5acb5 2012-06-28 12:00:57 Make th_base_lock nonrecursive This is necessary for making some thread libraries work with event.c, and might get better performance with others. The biggest change required here was that we needed to make some internal code that had previously called event_add and event_del call the nolock variants.
be7a95c6 2012-06-15 01:01:05 Make event_pending() threadsafe. (Commit message by Nick)
7d6aa5ee 2012-05-09 12:05:07 Add an event_base_loopcontinue() to tell libevent to rescan right away
c0e425ab 2012-05-09 11:06:06 Restore our priority-inversion-prevention code with deferreds Back when deferred_cb stuff had its own queue, the queue was always executed, but we never ran more than 16 callbacks per iteration. That made for two problems: 1: Because deferred_cb stuff would always run, and had no priority, it could cause priority inversion. 2: It doesn't respect the max_dispatch_interval code. Then, when I refactored deferred_cb to be a special case of event_callback, that solved the above issues, but made for two more issues: 3: Because deferred_cb stuff would always get the default priority, it could could low-priority bufferevents to get too much priority. 4: With code like bufferevent_pair, it's easy to get into a situation where two deferreds keep adding one another, preventing the event loop from ever actually scanning for more events. This commit fixes the above by giving deferreds a better notion of priorities, and by limiting the number of deferreds that can be added to the _current_ loop iteration's active queues. (Extra deferreds are put into the active_later state.) That isn't an all-purpose priority inversion solution, of course: for that, you may need to mess around with max_dispatch_interval.
581b5beb 2012-05-09 10:50:07 Give event_base_process_active a single exit path
c46cb9c3 2012-05-09 10:49:28 Make event_base_getnpriorities work with old "implicit base" code
f90e2559 2012-05-08 17:46:46 New event_get_priority() function to return an event's priority