Lines Matching refs:base

150 static void event_queue_make_later_events_active(struct event_base *base);
152 static int evthread_make_base_notifiable_nolock_(struct event_base *base);
170 static int evthread_notify_base(struct event_base *base);
404 #define EVENT_BASE_ASSERT_LOCKED(base) \ argument
405 EVLOCK_ASSERT_LOCKED((base)->th_base_lock)
417 gettime(struct event_base *base, struct timeval *tp) in gettime() argument
419 EVENT_BASE_ASSERT_LOCKED(base); in gettime()
421 if (base->tv_cache.tv_sec) { in gettime()
422 *tp = base->tv_cache; in gettime()
426 if (evutil_gettime_monotonic_(&base->monotonic_timer, tp) == -1) { in gettime()
430 if (base->last_updated_clock_diff + CLOCK_SYNC_INTERVAL in gettime()
434 evutil_timersub(&tv, tp, &base->tv_clock_diff); in gettime()
435 base->last_updated_clock_diff = tp->tv_sec; in gettime()
442 event_base_gettimeofday_cached(struct event_base *base, struct timeval *tv) in event_base_gettimeofday_cached() argument
445 if (!base) { in event_base_gettimeofday_cached()
446 base = current_base; in event_base_gettimeofday_cached()
451 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_gettimeofday_cached()
452 if (base->tv_cache.tv_sec == 0) { in event_base_gettimeofday_cached()
455 evutil_timeradd(&base->tv_cache, &base->tv_clock_diff, tv); in event_base_gettimeofday_cached()
458 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_gettimeofday_cached()
464 clear_time_cache(struct event_base *base) in clear_time_cache() argument
466 base->tv_cache.tv_sec = 0; in clear_time_cache()
471 update_time_cache(struct event_base *base) in update_time_cache() argument
473 base->tv_cache.tv_sec = 0; in update_time_cache()
474 if (!(base->flags & EVENT_BASE_FLAG_NO_CACHE_TIME)) in update_time_cache()
475 gettime(base, &base->tv_cache); in update_time_cache()
479 event_base_update_cache_time(struct event_base *base) in event_base_update_cache_time() argument
482 if (!base) { in event_base_update_cache_time()
483 base = current_base; in event_base_update_cache_time()
488 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_update_cache_time()
489 if (base->running_loop) in event_base_update_cache_time()
490 update_time_cache(base); in event_base_update_cache_time()
491 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_update_cache_time()
511 struct event_base *base = event_base_new_with_config(NULL); in event_init() local
513 if (base == NULL) { in event_init()
518 current_base = base; in event_init()
520 return (base); in event_init()
526 struct event_base *base = NULL; in event_base_new() local
529 base = event_base_new_with_config(cfg); in event_base_new()
532 return base; in event_base_new()
568 event_base_get_features(const struct event_base *base) in event_base_get_features() argument
570 return base->evsel->features; in event_base_get_features()
612 struct event_base *base; in event_base_new_with_config() local
619 if ((base = mm_calloc(1, sizeof(struct event_base))) == NULL) { in event_base_new_with_config()
625 base->flags = cfg->flags; in event_base_new_with_config()
638 base->flags |= EVENT_BASE_FLAG_PRECISE_TIMER; in event_base_new_with_config()
642 evutil_configure_monotonic_time_(&base->monotonic_timer, flags); in event_base_new_with_config()
644 gettime(base, &tmp); in event_base_new_with_config()
647 min_heap_ctor_(&base->timeheap); in event_base_new_with_config()
649 base->sig.ev_signal_pair[0] = -1; in event_base_new_with_config()
650 base->sig.ev_signal_pair[1] = -1; in event_base_new_with_config()
651 base->th_notify_fd[0] = -1; in event_base_new_with_config()
652 base->th_notify_fd[1] = -1; in event_base_new_with_config()
654 TAILQ_INIT(&base->active_later_queue); in event_base_new_with_config()
656 evmap_io_initmap_(&base->io); in event_base_new_with_config()
657 evmap_signal_initmap_(&base->sigmap); in event_base_new_with_config()
658 event_changelist_init_(&base->changelist); in event_base_new_with_config()
660 base->evbase = NULL; in event_base_new_with_config()
663 memcpy(&base->max_dispatch_time, in event_base_new_with_config()
665 base->limit_callbacks_after_prio = in event_base_new_with_config()
668 base->max_dispatch_time.tv_sec = -1; in event_base_new_with_config()
669 base->limit_callbacks_after_prio = 1; in event_base_new_with_config()
672 base->max_dispatch_callbacks = cfg->max_dispatch_callbacks; in event_base_new_with_config()
674 base->max_dispatch_callbacks = INT_MAX; in event_base_new_with_config()
676 if (base->max_dispatch_callbacks == INT_MAX && in event_base_new_with_config()
677 base->max_dispatch_time.tv_sec == -1) in event_base_new_with_config()
678 base->limit_callbacks_after_prio = INT_MAX; in event_base_new_with_config()
680 for (i = 0; eventops[i] && !base->evbase; i++) { in event_base_new_with_config()
696 base->evsel = eventops[i]; in event_base_new_with_config()
698 base->evbase = base->evsel->init(base); in event_base_new_with_config()
701 if (base->evbase == NULL) { in event_base_new_with_config()
704 base->evsel = NULL; in event_base_new_with_config()
705 event_base_free(base); in event_base_new_with_config()
710 event_msgx("libevent using: %s", base->evsel->name); in event_base_new_with_config()
713 if (event_base_priority_init(base, 1) < 0) { in event_base_new_with_config()
714 event_base_free(base); in event_base_new_with_config()
728 EVTHREAD_ALLOC_LOCK(base->th_base_lock, 0); in event_base_new_with_config()
729 EVTHREAD_ALLOC_COND(base->current_event_cond); in event_base_new_with_config()
730 r = evthread_make_base_notifiable(base); in event_base_new_with_config()
733 event_base_free(base); in event_base_new_with_config()
741 event_base_start_iocp_(base, cfg->n_cpus_hint); in event_base_new_with_config()
744 return (base); in event_base_new_with_config()
748 event_base_start_iocp_(struct event_base *base, int n_cpus) in event_base_start_iocp_() argument
751 if (base->iocp) in event_base_start_iocp_()
753 base->iocp = event_iocp_port_launch_(n_cpus); in event_base_start_iocp_()
754 if (!base->iocp) { in event_base_start_iocp_()
765 event_base_stop_iocp_(struct event_base *base) in event_base_stop_iocp_() argument
770 if (!base->iocp) in event_base_stop_iocp_()
772 rv = event_iocp_shutdown_(base->iocp, -1); in event_base_stop_iocp_()
774 base->iocp = NULL; in event_base_stop_iocp_()
779 event_base_cancel_single_callback_(struct event_base *base, in event_base_cancel_single_callback_() argument
792 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_cancel_single_callback_()
793 event_callback_cancel_nolock_(base, evcb, 1); in event_base_cancel_single_callback_()
794 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_cancel_single_callback_()
818 static int event_base_free_queues_(struct event_base *base, int run_finalizers) in event_base_free_queues_() argument
822 for (i = 0; i < base->nactivequeues; ++i) { in event_base_free_queues_()
824 for (evcb = TAILQ_FIRST(&base->activequeues[i]); evcb; ) { in event_base_free_queues_()
826 deleted += event_base_cancel_single_callback_(base, evcb, run_finalizers); in event_base_free_queues_()
833 while ((evcb = TAILQ_FIRST(&base->active_later_queue))) { in event_base_free_queues_()
834 deleted += event_base_cancel_single_callback_(base, evcb, run_finalizers); in event_base_free_queues_()
842 event_base_free_(struct event_base *base, int run_finalizers) in event_base_free_() argument
851 if (base == NULL && current_base) in event_base_free_()
852 base = current_base; in event_base_free_()
854 if (base == NULL) { in event_base_free_()
861 event_base_stop_iocp_(base); in event_base_free_()
865 if (base->th_notify_fd[0] != -1) { in event_base_free_()
866 event_del(&base->th_notify); in event_base_free_()
867 EVUTIL_CLOSESOCKET(base->th_notify_fd[0]); in event_base_free_()
868 if (base->th_notify_fd[1] != -1) in event_base_free_()
869 EVUTIL_CLOSESOCKET(base->th_notify_fd[1]); in event_base_free_()
870 base->th_notify_fd[0] = -1; in event_base_free_()
871 base->th_notify_fd[1] = -1; in event_base_free_()
872 event_debug_unassign(&base->th_notify); in event_base_free_()
876 evmap_delete_all_(base); in event_base_free_()
878 while ((ev = min_heap_top_(&base->timeheap)) != NULL) { in event_base_free_()
882 for (i = 0; i < base->n_common_timeouts; ++i) { in event_base_free_()
884 base->common_timeout_queues[i]; in event_base_free_()
898 if (base->common_timeout_queues) in event_base_free_()
899 mm_free(base->common_timeout_queues); in event_base_free_()
910 int ii = event_base_free_queues_(base, run_finalizers); in event_base_free_()
922 while (LIST_FIRST(&base->once_events)) { in event_base_free_()
923 struct event_once *eonce = LIST_FIRST(&base->once_events); in event_base_free_()
928 if (base->evsel != NULL && base->evsel->dealloc != NULL) in event_base_free_()
929 base->evsel->dealloc(base); in event_base_free_()
931 for (i = 0; i < base->nactivequeues; ++i) in event_base_free_()
932 EVUTIL_ASSERT(TAILQ_EMPTY(&base->activequeues[i])); in event_base_free_()
934 EVUTIL_ASSERT(min_heap_empty_(&base->timeheap)); in event_base_free_()
935 min_heap_dtor_(&base->timeheap); in event_base_free_()
937 mm_free(base->activequeues); in event_base_free_()
939 evmap_io_clear_(&base->io); in event_base_free_()
940 evmap_signal_clear_(&base->sigmap); in event_base_free_()
941 event_changelist_freemem_(&base->changelist); in event_base_free_()
943 EVTHREAD_FREE_LOCK(base->th_base_lock, 0); in event_base_free_()
944 EVTHREAD_FREE_COND(base->current_event_cond); in event_base_free_()
947 if (base == current_base) in event_base_free_()
949 mm_free(base); in event_base_free_()
953 event_base_free_nofinalize(struct event_base *base) in event_base_free_nofinalize() argument
955 event_base_free_(base, 0); in event_base_free_nofinalize()
959 event_base_free(struct event_base *base) in event_base_free() argument
961 event_base_free_(base, 1); in event_base_free()
985 event_reinit(struct event_base *base) in event_reinit() argument
992 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_reinit()
994 evsel = base->evsel; in event_reinit()
1006 base->evsel = &nil_eventop; in event_reinit()
1015 if (base->sig.ev_signal_added) { in event_reinit()
1016 event_del_nolock_(&base->sig.ev_signal, EVENT_DEL_AUTOBLOCK); in event_reinit()
1017 event_debug_unassign(&base->sig.ev_signal); in event_reinit()
1018 memset(&base->sig.ev_signal, 0, sizeof(base->sig.ev_signal)); in event_reinit()
1020 base->sig.ev_signal_added = 0; in event_reinit()
1022 if (base->sig.ev_signal_pair[0] != -1) in event_reinit()
1023 EVUTIL_CLOSESOCKET(base->sig.ev_signal_pair[0]); in event_reinit()
1024 if (base->sig.ev_signal_pair[1] != -1) in event_reinit()
1025 EVUTIL_CLOSESOCKET(base->sig.ev_signal_pair[1]); in event_reinit()
1026 if (base->th_notify_fn != NULL) { in event_reinit()
1028 base->th_notify_fn = NULL; in event_reinit()
1030 if (base->th_notify_fd[0] != -1) { in event_reinit()
1031 event_del_nolock_(&base->th_notify, EVENT_DEL_AUTOBLOCK); in event_reinit()
1032 EVUTIL_CLOSESOCKET(base->th_notify_fd[0]); in event_reinit()
1033 if (base->th_notify_fd[1] != -1) in event_reinit()
1034 EVUTIL_CLOSESOCKET(base->th_notify_fd[1]); in event_reinit()
1035 base->th_notify_fd[0] = -1; in event_reinit()
1036 base->th_notify_fd[1] = -1; in event_reinit()
1037 event_debug_unassign(&base->th_notify); in event_reinit()
1041 base->evsel = evsel; in event_reinit()
1053 if (base->evsel->dealloc != NULL) in event_reinit()
1054 base->evsel->dealloc(base); in event_reinit()
1055 base->evbase = evsel->init(base); in event_reinit()
1056 if (base->evbase == NULL) { in event_reinit()
1066 event_changelist_freemem_(&base->changelist); in event_reinit()
1071 if (evmap_reinit_(base) < 0) in event_reinit()
1074 res = evsig_init_(base); in event_reinit()
1076 res = event_add_nolock_(&base->sig.ev_signal, NULL, 0); in event_reinit()
1078 base->sig.ev_signal_added = 1; in event_reinit()
1085 res = evthread_make_base_notifiable_nolock_(base); in event_reinit()
1088 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_reinit()
1094 event_gettime_monotonic(struct event_base *base, struct timeval *tv) in event_gettime_monotonic() argument
1098 if (base && tv) { in event_gettime_monotonic()
1099 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_gettime_monotonic()
1100 rv = evutil_gettime_monotonic_(&(base->monotonic_timer), tv); in event_gettime_monotonic()
1101 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_gettime_monotonic()
1244 event_base_priority_init(struct event_base *base, int npriorities) in event_base_priority_init() argument
1249 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_priority_init()
1251 if (N_ACTIVE_CALLBACKS(base) || npriorities < 1 in event_base_priority_init()
1255 if (npriorities == base->nactivequeues) in event_base_priority_init()
1258 if (base->nactivequeues) { in event_base_priority_init()
1259 mm_free(base->activequeues); in event_base_priority_init()
1260 base->nactivequeues = 0; in event_base_priority_init()
1264 base->activequeues = (struct evcallback_list *) in event_base_priority_init()
1266 if (base->activequeues == NULL) { in event_base_priority_init()
1270 base->nactivequeues = npriorities; in event_base_priority_init()
1272 for (i = 0; i < base->nactivequeues; ++i) { in event_base_priority_init()
1273 TAILQ_INIT(&base->activequeues[i]); in event_base_priority_init()
1279 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_priority_init()
1284 event_base_get_npriorities(struct event_base *base) in event_base_get_npriorities() argument
1288 if (base == NULL) in event_base_get_npriorities()
1289 base = current_base; in event_base_get_npriorities()
1291 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_get_npriorities()
1292 n = base->nactivequeues; in event_base_get_npriorities()
1293 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_get_npriorities()
1298 event_base_get_num_events(struct event_base *base, unsigned int type) in event_base_get_num_events() argument
1302 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_get_num_events()
1305 r += base->event_count_active; in event_base_get_num_events()
1308 r += base->virtual_event_count; in event_base_get_num_events()
1311 r += base->event_count; in event_base_get_num_events()
1313 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_get_num_events()
1319 event_base_get_max_events(struct event_base *base, unsigned int type, int clear) in event_base_get_max_events() argument
1323 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_get_max_events()
1326 r += base->event_count_active_max; in event_base_get_max_events()
1328 base->event_count_active_max = 0; in event_base_get_max_events()
1332 r += base->virtual_event_count_max; in event_base_get_max_events()
1334 base->virtual_event_count_max = 0; in event_base_get_max_events()
1338 r += base->event_count_max; in event_base_get_max_events()
1340 base->event_count_max = 0; in event_base_get_max_events()
1343 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_get_max_events()
1350 event_haveevents(struct event_base *base) in event_haveevents() argument
1353 return (base->virtual_event_count > 0 || base->event_count > 0); in event_haveevents()
1358 event_signal_closure(struct event_base *base, struct event *ev) in event_signal_closure() argument
1367 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_signal_closure()
1375 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_signal_closure()
1376 should_break = base->event_break; in event_signal_closure()
1377 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_signal_closure()
1414 const struct event_base *base) in is_common_timeout() argument
1420 return idx < base->n_common_timeouts; in is_common_timeout()
1435 get_common_timeout_list(struct event_base *base, const struct timeval *tv) in get_common_timeout_list() argument
1437 return base->common_timeout_queues[COMMON_TIMEOUT_IDX(tv)]; in get_common_timeout_list()
1443 struct event_base *base)
1446 &get_common_timeout_list(base, tv)->duration;
1471 struct event_base *base = ctl->base; in common_timeout_callback() local
1473 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in common_timeout_callback()
1474 gettime(base, &now); in common_timeout_callback()
1486 EVBASE_RELEASE_LOCK(base, th_base_lock); in common_timeout_callback()
1492 event_base_init_common_timeout(struct event_base *base, in event_base_init_common_timeout() argument
1500 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_init_common_timeout()
1503 if (is_common_timeout(duration, base)) in event_base_init_common_timeout()
1509 for (i = 0; i < base->n_common_timeouts; ++i) { in event_base_init_common_timeout()
1511 base->common_timeout_queues[i]; in event_base_init_common_timeout()
1515 EVUTIL_ASSERT(is_common_timeout(&ctl->duration, base)); in event_base_init_common_timeout()
1520 if (base->n_common_timeouts == MAX_COMMON_TIMEOUTS) { in event_base_init_common_timeout()
1526 if (base->n_common_timeouts_allocated == base->n_common_timeouts) { in event_base_init_common_timeout()
1527 int n = base->n_common_timeouts < 16 ? 16 : in event_base_init_common_timeout()
1528 base->n_common_timeouts*2; in event_base_init_common_timeout()
1530 mm_realloc(base->common_timeout_queues, in event_base_init_common_timeout()
1536 base->n_common_timeouts_allocated = n; in event_base_init_common_timeout()
1537 base->common_timeout_queues = newqueues; in event_base_init_common_timeout()
1548 (base->n_common_timeouts << COMMON_TIMEOUT_IDX_SHIFT); in event_base_init_common_timeout()
1549 evtimer_assign(&new_ctl->timeout_event, base, in event_base_init_common_timeout()
1553 new_ctl->base = base; in event_base_init_common_timeout()
1554 base->common_timeout_queues[base->n_common_timeouts++] = new_ctl; in event_base_init_common_timeout()
1559 EVUTIL_ASSERT(is_common_timeout(result, base)); in event_base_init_common_timeout()
1561 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_init_common_timeout()
1567 event_persist_closure(struct event_base *base, struct event *ev) in event_persist_closure() argument
1586 gettime(base, &now); in event_persist_closure()
1587 if (is_common_timeout(&ev->ev_timeout, base)) { in event_persist_closure()
1625 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_persist_closure()
1639 event_process_active_single_queue(struct event_base *base, in event_process_active_single_queue() argument
1654 event_queue_remove_active(base, evcb); in event_process_active_single_queue()
1665 event_queue_remove_active(base, evcb); in event_process_active_single_queue()
1675 base->current_event = evcb; in event_process_active_single_queue()
1677 base->current_event_waiters = 0; in event_process_active_single_queue()
1683 event_signal_closure(base, ev); in event_process_active_single_queue()
1687 event_persist_closure(base, ev); in event_process_active_single_queue()
1695 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_process_active_single_queue()
1701 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_process_active_single_queue()
1710 base->current_event = NULL; in event_process_active_single_queue()
1713 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_process_active_single_queue()
1722 base->current_event = NULL; in event_process_active_single_queue()
1724 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_process_active_single_queue()
1732 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_process_active_single_queue()
1733 base->current_event = NULL; in event_process_active_single_queue()
1735 if (base->current_event_waiters) { in event_process_active_single_queue()
1736 base->current_event_waiters = 0; in event_process_active_single_queue()
1737 EVTHREAD_COND_BROADCAST(base->current_event_cond); in event_process_active_single_queue()
1741 if (base->event_break) in event_process_active_single_queue()
1747 update_time_cache(base); in event_process_active_single_queue()
1748 gettime(base, &now); in event_process_active_single_queue()
1752 if (base->event_continue) in event_process_active_single_queue()
1765 event_process_active(struct event_base *base) in event_process_active() argument
1772 const int maxcb = base->max_dispatch_callbacks; in event_process_active()
1773 const int limit_after_prio = base->limit_callbacks_after_prio; in event_process_active()
1774 if (base->max_dispatch_time.tv_sec >= 0) { in event_process_active()
1775 update_time_cache(base); in event_process_active()
1776 gettime(base, &tv); in event_process_active()
1777 evutil_timeradd(&base->max_dispatch_time, &tv, &tv); in event_process_active()
1783 for (i = 0; i < base->nactivequeues; ++i) { in event_process_active()
1784 if (TAILQ_FIRST(&base->activequeues[i]) != NULL) { in event_process_active()
1785 base->event_running_priority = i; in event_process_active()
1786 activeq = &base->activequeues[i]; in event_process_active()
1788 c = event_process_active_single_queue(base, activeq, in event_process_active()
1791 c = event_process_active_single_queue(base, activeq, in event_process_active()
1804 base->event_running_priority = -1; in event_process_active()
1826 event_base_get_method(const struct event_base *base) in event_base_get_method() argument
1828 EVUTIL_ASSERT(base); in event_base_get_method()
1829 return (base->evsel->name); in event_base_get_method()
1837 struct event_base *base = arg; in event_loopexit_cb() local
1838 base->event_gotterm = 1; in event_loopexit_cb()
1928 event_base_loop(struct event_base *base, int flags) in event_base_loop() argument
1930 const struct eventop *evsel = base->evsel; in event_base_loop()
1937 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_loop()
1939 if (base->running_loop) { in event_base_loop()
1942 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_loop()
1946 base->running_loop = 1; in event_base_loop()
1948 clear_time_cache(base); in event_base_loop()
1950 if (base->sig.ev_signal_added && base->sig.ev_n_signals_added) in event_base_loop()
1951 evsig_set_base_(base); in event_base_loop()
1956 base->th_owner_id = EVTHREAD_GET_ID(); in event_base_loop()
1959 base->event_gotterm = base->event_break = 0; in event_base_loop()
1962 base->event_continue = 0; in event_base_loop()
1963 base->n_deferreds_queued = 0; in event_base_loop()
1966 if (base->event_gotterm) { in event_base_loop()
1970 if (base->event_break) { in event_base_loop()
1975 if (!N_ACTIVE_CALLBACKS(base) && !(flags & EVLOOP_NONBLOCK)) { in event_base_loop()
1976 timeout_next(base, &tv_p); in event_base_loop()
1987 !event_haveevents(base) && !N_ACTIVE_CALLBACKS(base)) { in event_base_loop()
1993 event_queue_make_later_events_active(base); in event_base_loop()
1995 clear_time_cache(base); in event_base_loop()
1997 res = evsel->dispatch(base, tv_p); in event_base_loop()
2006 update_time_cache(base); in event_base_loop()
2008 timeout_process(base); in event_base_loop()
2010 if (N_ACTIVE_CALLBACKS(base)) { in event_base_loop()
2011 int n = event_process_active(base); in event_base_loop()
2013 && N_ACTIVE_CALLBACKS(base) == 0 in event_base_loop()
2022 clear_time_cache(base); in event_base_loop()
2023 base->running_loop = 0; in event_base_loop()
2025 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_loop()
2056 event_base_once(struct event_base *base, evutil_socket_t fd, short events, in event_base_once() argument
2064 if (!base) in event_base_once()
2079 evtimer_assign(&eonce->ev, base, event_once_cb, eonce); in event_base_once()
2091 event_assign(&eonce->ev, base, fd, events, event_once_cb, eonce); in event_base_once()
2099 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_once()
2109 LIST_INSERT_HEAD(&base->once_events, eonce, next_once); in event_base_once()
2111 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_once()
2118 event_assign(struct event *ev, struct event_base *base, evutil_socket_t fd, short events, void (*ca… in event_assign() argument
2120 if (!base) in event_assign()
2121 base = current_base; in event_assign()
2129 ev->ev_base = base; in event_assign()
2158 if (base != NULL) { in event_assign()
2160 ev->ev_pri = base->nactivequeues / 2; in event_assign()
2169 event_base_set(struct event_base *base, struct event *ev) in event_base_set() argument
2177 ev->ev_base = base; in event_base_set()
2178 ev->ev_pri = base->nactivequeues/2; in event_base_set()
2199 event_base_get_running_event(struct event_base *base) in event_base_get_running_event() argument
2202 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_get_running_event()
2203 if (EVBASE_IN_THREAD(base)) { in event_base_get_running_event()
2204 struct event_callback *evcb = base->current_event; in event_base_get_running_event()
2208 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_get_running_event()
2213 event_new(struct event_base *base, evutil_socket_t fd, short events, void (*cb)(evutil_socket_t, sh… in event_new() argument
2219 if (event_assign(ev, base, fd, events, cb, arg) < 0) { in event_new()
2252 event_finalize_nolock_(struct event_base *base, unsigned flags, struct event *ev, event_finalize_ca… in event_finalize_nolock_() argument
2269 struct event_base *base = ev->ev_base; in event_finalize_impl_() local
2270 if (EVUTIL_FAILURE_CHECK(!base)) { in event_finalize_impl_()
2275 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_finalize_impl_()
2276 r = event_finalize_nolock_(base, flags, ev, cb); in event_finalize_impl_()
2277 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_finalize_impl_()
2294 event_callback_finalize_nolock_(struct event_base *base, unsigned flags, struct event_callback *evc… in event_callback_finalize_nolock_() argument
2301 event_callback_cancel_nolock_(base, evcb, 0); /*XXX can this fail?*/ in event_callback_finalize_nolock_()
2306 event_callback_activate_nolock_(base, evcb); /* XXX can this really fail?*/ in event_callback_finalize_nolock_()
2311 event_callback_finalize_(struct event_base *base, unsigned flags, struct event_callback *evcb, void… in event_callback_finalize_() argument
2313 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_callback_finalize_()
2314 event_callback_finalize_nolock_(base, flags, evcb, cb); in event_callback_finalize_()
2315 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_callback_finalize_()
2322 event_callback_finalize_many_(struct event_base *base, int n_cbs, struct event_callback **evcbs, vo… in event_callback_finalize_many_() argument
2326 if (base == NULL) in event_callback_finalize_many_()
2327 base = current_base; in event_callback_finalize_many_()
2329 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_callback_finalize_many_()
2338 if (evcb == base->current_event) { in event_callback_finalize_many_()
2339 event_callback_finalize_nolock_(base, 0, evcb, cb); in event_callback_finalize_many_()
2342 event_callback_cancel_nolock_(base, evcb, 0); in event_callback_finalize_many_()
2348 event_callback_finalize_nolock_(base, 0, evcbs[0], cb); in event_callback_finalize_many_()
2351 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_callback_finalize_many_()
2512 evthread_notify_base_default(struct event_base *base) in evthread_notify_base_default() argument
2518 r = send(base->th_notify_fd[1], buf, 1, 0); in evthread_notify_base_default()
2520 r = write(base->th_notify_fd[1], buf, 1); in evthread_notify_base_default()
2529 evthread_notify_base_eventfd(struct event_base *base) in evthread_notify_base_eventfd() argument
2534 r = write(base->th_notify_fd[0], (void*) &msg, sizeof(msg)); in evthread_notify_base_eventfd()
2546 evthread_notify_base(struct event_base *base) in evthread_notify_base() argument
2548 EVENT_BASE_ASSERT_LOCKED(base); in evthread_notify_base()
2549 if (!base->th_notify_fn) in evthread_notify_base()
2551 if (base->is_notify_pending) in evthread_notify_base()
2553 base->is_notify_pending = 1; in evthread_notify_base()
2554 return base->th_notify_fn(base); in evthread_notify_base()
2562 struct event_base *base = ev->ev_base; in event_remove_timer_nolock_() local
2564 EVENT_BASE_ASSERT_LOCKED(base); in event_remove_timer_nolock_()
2571 event_queue_remove_timeout(base, ev); in event_remove_timer_nolock_()
2605 struct event_base *base = ev->ev_base; in event_add_nolock_() local
2609 EVENT_BASE_ASSERT_LOCKED(base); in event_add_nolock_()
2634 if (min_heap_reserve_(&base->timeheap, in event_add_nolock_()
2635 1 + min_heap_size_(&base->timeheap)) == -1) in event_add_nolock_()
2644 if (base->current_event == event_to_event_callback(ev) && in event_add_nolock_()
2646 && !EVBASE_IN_THREAD(base)) { in event_add_nolock_()
2647 ++base->current_event_waiters; in event_add_nolock_()
2648 EVTHREAD_COND_WAIT(base->current_event_cond, base->th_base_lock); in event_add_nolock_()
2655 res = evmap_io_add_(base, ev->ev_fd, ev); in event_add_nolock_()
2657 res = evmap_signal_add_(base, (int)ev->ev_fd, ev); in event_add_nolock_()
2659 event_queue_insert_inserted(base, ev); in event_add_nolock_()
2690 event_queue_remove_timeout(base, ev); in event_add_nolock_()
2709 event_queue_remove_active(base, event_to_event_callback(ev)); in event_add_nolock_()
2712 gettime(base, &now); in event_add_nolock_()
2714 common_timeout = is_common_timeout(tv, base); in event_add_nolock_()
2716 was_common = is_common_timeout(&ev->ev_timeout, base); in event_add_nolock_()
2737 event_queue_reinsert_timeout(base, ev, was_common, common_timeout, old_timeout_idx); in event_add_nolock_()
2739 event_queue_insert_timeout(base, ev); in event_add_nolock_()
2744 get_common_timeout_list(base, &ev->ev_timeout); in event_add_nolock_()
2758 else if ((top = min_heap_top_(&base->timeheap)) != NULL && in event_add_nolock_()
2765 if (res != -1 && notify && EVBASE_NEED_NOTIFY(base)) in event_add_nolock_()
2766 evthread_notify_base(base); in event_add_nolock_()
2777 struct event_base *base = ev->ev_base; in event_del_() local
2779 if (EVUTIL_FAILURE_CHECK(!base)) { in event_del_()
2784 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_del_()
2786 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_del_()
2817 struct event_base *base; in event_del_nolock_() local
2836 base = ev->ev_base; in event_del_nolock_()
2856 event_queue_remove_timeout(base, ev); in event_del_nolock_()
2860 event_queue_remove_active(base, event_to_event_callback(ev)); in event_del_nolock_()
2862 event_queue_remove_active_later(base, event_to_event_callback(ev)); in event_del_nolock_()
2865 event_queue_remove_inserted(base, ev); in event_del_nolock_()
2867 res = evmap_io_del_(base, ev->ev_fd, ev); in event_del_nolock_()
2869 res = evmap_signal_del_(base, (int)ev->ev_fd, ev); in event_del_nolock_()
2877 if (!event_haveevents(base) && !N_ACTIVE_CALLBACKS(base)) in event_del_nolock_()
2882 if (res != -1 && notify && EVBASE_NEED_NOTIFY(base)) in event_del_nolock_()
2883 evthread_notify_base(base); in event_del_nolock_()
2894 base->current_event == event_to_event_callback(ev) && in event_del_nolock_()
2895 !EVBASE_IN_THREAD(base) && in event_del_nolock_()
2897 ++base->current_event_waiters; in event_del_nolock_()
2898 EVTHREAD_COND_WAIT(base->current_event_cond, base->th_base_lock); in event_del_nolock_()
2926 struct event_base *base; in event_active_nolock_() local
2931 base = ev->ev_base; in event_active_nolock_()
2932 EVENT_BASE_ASSERT_LOCKED(base); in event_active_nolock_()
2956 if (ev->ev_pri < base->event_running_priority) in event_active_nolock_()
2957 base->event_continue = 1; in event_active_nolock_()
2961 if (base->current_event == event_to_event_callback(ev) && in event_active_nolock_()
2962 !EVBASE_IN_THREAD(base)) { in event_active_nolock_()
2963 ++base->current_event_waiters; in event_active_nolock_()
2964 EVTHREAD_COND_WAIT(base->current_event_cond, base->th_base_lock); in event_active_nolock_()
2971 event_callback_activate_nolock_(base, event_to_event_callback(ev)); in event_active_nolock_()
2985 struct event_base *base = ev->ev_base; in event_active_later_nolock_() local
2986 EVENT_BASE_ASSERT_LOCKED(base); in event_active_later_nolock_()
2996 event_callback_activate_later_nolock_(base, event_to_event_callback(ev)); in event_active_later_nolock_()
3000 event_callback_activate_(struct event_base *base, in event_callback_activate_() argument
3004 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_callback_activate_()
3005 r = event_callback_activate_nolock_(base, evcb); in event_callback_activate_()
3006 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_callback_activate_()
3011 event_callback_activate_nolock_(struct event_base *base, in event_callback_activate_nolock_() argument
3024 event_queue_remove_active_later(base, evcb); in event_callback_activate_nolock_()
3033 event_queue_insert_active(base, evcb); in event_callback_activate_nolock_()
3035 if (EVBASE_NEED_NOTIFY(base)) in event_callback_activate_nolock_()
3036 evthread_notify_base(base); in event_callback_activate_nolock_()
3042 event_callback_activate_later_nolock_(struct event_base *base, in event_callback_activate_later_nolock_() argument
3048 event_queue_insert_active_later(base, evcb); in event_callback_activate_later_nolock_()
3049 if (EVBASE_NEED_NOTIFY(base)) in event_callback_activate_later_nolock_()
3050 evthread_notify_base(base); in event_callback_activate_later_nolock_()
3055 event_callback_init_(struct event_base *base, in event_callback_init_() argument
3059 cb->evcb_pri = base->nactivequeues - 1; in event_callback_init_()
3063 event_callback_cancel_(struct event_base *base, in event_callback_cancel_() argument
3067 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_callback_cancel_()
3068 r = event_callback_cancel_nolock_(base, evcb, 0); in event_callback_cancel_()
3069 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_callback_cancel_()
3074 event_callback_cancel_nolock_(struct event_base *base, in event_callback_cancel_nolock_() argument
3091 event_queue_remove_active(base, evcb); in event_callback_cancel_nolock_()
3094 event_queue_remove_active_later(base, evcb); in event_callback_cancel_nolock_()
3120 event_deferred_cb_cancel_(struct event_base *base, struct event_callback *cb) in event_deferred_cb_cancel_() argument
3122 if (!base) in event_deferred_cb_cancel_()
3123 base = current_base; in event_deferred_cb_cancel_()
3124 event_callback_cancel_(base, cb); in event_deferred_cb_cancel_()
3129 event_deferred_cb_schedule_(struct event_base *base, struct event_callback *cb) in event_deferred_cb_schedule_() argument
3132 if (!base) in event_deferred_cb_schedule_()
3133 base = current_base; in event_deferred_cb_schedule_()
3134 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_deferred_cb_schedule_()
3135 if (base->n_deferreds_queued > MAX_DEFERREDS_QUEUED) { in event_deferred_cb_schedule_()
3136 r = event_callback_activate_later_nolock_(base, cb); in event_deferred_cb_schedule_()
3138 r = event_callback_activate_nolock_(base, cb); in event_deferred_cb_schedule_()
3140 ++base->n_deferreds_queued; in event_deferred_cb_schedule_()
3143 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_deferred_cb_schedule_()
3148 timeout_next(struct event_base *base, struct timeval **tv_p) in timeout_next() argument
3156 ev = min_heap_top_(&base->timeheap); in timeout_next()
3164 if (gettime(base, &now) == -1) { in timeout_next()
3186 timeout_process(struct event_base *base) in timeout_process() argument
3192 if (min_heap_empty_(&base->timeheap)) { in timeout_process()
3196 gettime(base, &now); in timeout_process()
3198 while ((ev = min_heap_top_(&base->timeheap))) { in timeout_process()
3221 #define DECR_EVENT_COUNT(base,flags) \ argument
3222 ((base)->event_count -= !((flags) & EVLIST_INTERNAL))
3223 #define INCR_EVENT_COUNT(base,flags) do { \ argument
3224 ((base)->event_count += !((flags) & EVLIST_INTERNAL)); \
3225 MAX_EVENT_COUNT((base)->event_count_max, (base)->event_count); \
3229 event_queue_remove_inserted(struct event_base *base, struct event *ev) in event_queue_remove_inserted() argument
3231 EVENT_BASE_ASSERT_LOCKED(base); in event_queue_remove_inserted()
3237 DECR_EVENT_COUNT(base, ev->ev_flags); in event_queue_remove_inserted()
3241 event_queue_remove_active(struct event_base *base, struct event_callback *evcb) in event_queue_remove_active() argument
3243 EVENT_BASE_ASSERT_LOCKED(base); in event_queue_remove_active()
3249 DECR_EVENT_COUNT(base, evcb->evcb_flags); in event_queue_remove_active()
3251 base->event_count_active--; in event_queue_remove_active()
3253 TAILQ_REMOVE(&base->activequeues[evcb->evcb_pri], in event_queue_remove_active()
3257 event_queue_remove_active_later(struct event_base *base, struct event_callback *evcb) in event_queue_remove_active_later() argument
3259 EVENT_BASE_ASSERT_LOCKED(base); in event_queue_remove_active_later()
3265 DECR_EVENT_COUNT(base, evcb->evcb_flags); in event_queue_remove_active_later()
3267 base->event_count_active--; in event_queue_remove_active_later()
3269 TAILQ_REMOVE(&base->active_later_queue, evcb, evcb_active_next); in event_queue_remove_active_later()
3272 event_queue_remove_timeout(struct event_base *base, struct event *ev) in event_queue_remove_timeout() argument
3274 EVENT_BASE_ASSERT_LOCKED(base); in event_queue_remove_timeout()
3280 DECR_EVENT_COUNT(base, ev->ev_flags); in event_queue_remove_timeout()
3283 if (is_common_timeout(&ev->ev_timeout, base)) { in event_queue_remove_timeout()
3285 get_common_timeout_list(base, &ev->ev_timeout); in event_queue_remove_timeout()
3289 min_heap_erase_(&base->timeheap, ev); in event_queue_remove_timeout()
3296 event_queue_reinsert_timeout(struct event_base *base, struct event *ev, in event_queue_reinsert_timeout() argument
3301 event_queue_insert_timeout(base, ev); in event_queue_reinsert_timeout()
3307 ctl = base->common_timeout_queues[old_timeout_idx]; in event_queue_reinsert_timeout()
3310 ctl = get_common_timeout_list(base, &ev->ev_timeout); in event_queue_reinsert_timeout()
3314 ctl = base->common_timeout_queues[old_timeout_idx]; in event_queue_reinsert_timeout()
3317 min_heap_push_(&base->timeheap, ev); in event_queue_reinsert_timeout()
3320 min_heap_erase_(&base->timeheap, ev); in event_queue_reinsert_timeout()
3321 ctl = get_common_timeout_list(base, &ev->ev_timeout); in event_queue_reinsert_timeout()
3325 min_heap_adjust_(&base->timeheap, ev); in event_queue_reinsert_timeout()
3366 event_queue_insert_inserted(struct event_base *base, struct event *ev) in event_queue_insert_inserted() argument
3368 EVENT_BASE_ASSERT_LOCKED(base); in event_queue_insert_inserted()
3376 INCR_EVENT_COUNT(base, ev->ev_flags); in event_queue_insert_inserted()
3382 event_queue_insert_active(struct event_base *base, struct event_callback *evcb) in event_queue_insert_active() argument
3384 EVENT_BASE_ASSERT_LOCKED(base); in event_queue_insert_active()
3391 INCR_EVENT_COUNT(base, evcb->evcb_flags); in event_queue_insert_active()
3395 base->event_count_active++; in event_queue_insert_active()
3396 MAX_EVENT_COUNT(base->event_count_active_max, base->event_count_active); in event_queue_insert_active()
3397 EVUTIL_ASSERT(evcb->evcb_pri < base->nactivequeues); in event_queue_insert_active()
3398 TAILQ_INSERT_TAIL(&base->activequeues[evcb->evcb_pri], in event_queue_insert_active()
3403 event_queue_insert_active_later(struct event_base *base, struct event_callback *evcb) in event_queue_insert_active_later() argument
3405 EVENT_BASE_ASSERT_LOCKED(base); in event_queue_insert_active_later()
3411 INCR_EVENT_COUNT(base, evcb->evcb_flags); in event_queue_insert_active_later()
3413 base->event_count_active++; in event_queue_insert_active_later()
3414 MAX_EVENT_COUNT(base->event_count_active_max, base->event_count_active); in event_queue_insert_active_later()
3415 EVUTIL_ASSERT(evcb->evcb_pri < base->nactivequeues); in event_queue_insert_active_later()
3416 TAILQ_INSERT_TAIL(&base->active_later_queue, evcb, evcb_active_next); in event_queue_insert_active_later()
3420 event_queue_insert_timeout(struct event_base *base, struct event *ev) in event_queue_insert_timeout() argument
3422 EVENT_BASE_ASSERT_LOCKED(base); in event_queue_insert_timeout()
3430 INCR_EVENT_COUNT(base, ev->ev_flags); in event_queue_insert_timeout()
3434 if (is_common_timeout(&ev->ev_timeout, base)) { in event_queue_insert_timeout()
3436 get_common_timeout_list(base, &ev->ev_timeout); in event_queue_insert_timeout()
3439 min_heap_push_(&base->timeheap, ev); in event_queue_insert_timeout()
3444 event_queue_make_later_events_active(struct event_base *base) in event_queue_make_later_events_active() argument
3447 EVENT_BASE_ASSERT_LOCKED(base); in event_queue_make_later_events_active()
3449 while ((evcb = TAILQ_FIRST(&base->active_later_queue))) { in event_queue_make_later_events_active()
3450 TAILQ_REMOVE(&base->active_later_queue, evcb, evcb_active_next); in event_queue_make_later_events_active()
3452 EVUTIL_ASSERT(evcb->evcb_pri < base->nactivequeues); in event_queue_make_later_events_active()
3453 TAILQ_INSERT_TAIL(&base->activequeues[evcb->evcb_pri], evcb, evcb_active_next); in event_queue_make_later_events_active()
3454 base->n_deferreds_queued += (evcb->evcb_closure == EV_CLOSURE_CB_SELF); in event_queue_make_later_events_active()
3592 struct event_base *base = arg; in evthread_notify_drain_eventfd() local
3598 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in evthread_notify_drain_eventfd()
3599 base->is_notify_pending = 0; in evthread_notify_drain_eventfd()
3600 EVBASE_RELEASE_LOCK(base, th_base_lock); in evthread_notify_drain_eventfd()
3608 struct event_base *base = arg; in evthread_notify_drain_default() local
3617 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in evthread_notify_drain_default()
3618 base->is_notify_pending = 0; in evthread_notify_drain_default()
3619 EVBASE_RELEASE_LOCK(base, th_base_lock); in evthread_notify_drain_default()
3623 evthread_make_base_notifiable(struct event_base *base) in evthread_make_base_notifiable() argument
3626 if (!base) in evthread_make_base_notifiable()
3629 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in evthread_make_base_notifiable()
3630 r = evthread_make_base_notifiable_nolock_(base); in evthread_make_base_notifiable()
3631 EVBASE_RELEASE_LOCK(base, th_base_lock); in evthread_make_base_notifiable()
3636 evthread_make_base_notifiable_nolock_(struct event_base *base) in evthread_make_base_notifiable_nolock_() argument
3641 if (base->th_notify_fn != NULL) { in evthread_make_base_notifiable_nolock_()
3647 if (base->evsel == &kqops && event_kq_add_notify_event_(base) == 0) { in evthread_make_base_notifiable_nolock_()
3648 base->th_notify_fn = event_kq_notify_base_; in evthread_make_base_notifiable_nolock_()
3656 base->th_notify_fd[0] = evutil_eventfd_(0, in evthread_make_base_notifiable_nolock_()
3658 if (base->th_notify_fd[0] >= 0) { in evthread_make_base_notifiable_nolock_()
3659 base->th_notify_fd[1] = -1; in evthread_make_base_notifiable_nolock_()
3664 if (evutil_make_internal_pipe_(base->th_notify_fd) == 0) { in evthread_make_base_notifiable_nolock_()
3671 base->th_notify_fn = notify; in evthread_make_base_notifiable_nolock_()
3674 event_assign(&base->th_notify, base, base->th_notify_fd[0], in evthread_make_base_notifiable_nolock_()
3675 EV_READ|EV_PERSIST, cb, base); in evthread_make_base_notifiable_nolock_()
3678 base->th_notify.ev_flags |= EVLIST_INTERNAL; in evthread_make_base_notifiable_nolock_()
3679 event_priority_set(&base->th_notify, 0); in evthread_make_base_notifiable_nolock_()
3681 return event_add_nolock_(&base->th_notify, NULL, 0); in evthread_make_base_notifiable_nolock_()
3685 event_base_foreach_event_nolock_(struct event_base *base, in event_base_foreach_event_nolock_() argument
3693 if ((r = evmap_foreach_event_(base, fn, arg))) in event_base_foreach_event_nolock_()
3698 for (u = 0; u < base->timeheap.n; ++u) { in event_base_foreach_event_nolock_()
3699 ev = base->timeheap.p[u]; in event_base_foreach_event_nolock_()
3704 if ((r = fn(base, ev, arg))) in event_base_foreach_event_nolock_()
3710 for (i = 0; i < base->n_common_timeouts; ++i) { in event_base_foreach_event_nolock_()
3712 base->common_timeout_queues[i]; in event_base_foreach_event_nolock_()
3719 if ((r = fn(base, ev, arg))) in event_base_foreach_event_nolock_()
3726 for (i = 0; i < base->nactivequeues; ++i) { in event_base_foreach_event_nolock_()
3728 TAILQ_FOREACH(evcb, &base->activequeues[i], evcb_active_next) { in event_base_foreach_event_nolock_()
3736 if ((r = fn(base, ev, arg))) in event_base_foreach_event_nolock_()
3747 dump_inserted_event_fn(const struct event_base *base, const struct event *e, void *arg) in dump_inserted_event_fn() argument
3769 evutil_timeradd(&tv, &base->tv_clock_diff, &tv); in dump_inserted_event_fn()
3781 dump_active_event_fn(const struct event_base *base, const struct event *e, void *arg) in dump_active_event_fn() argument
3804 event_base_foreach_event(struct event_base *base, in event_base_foreach_event() argument
3808 if ((!fn) || (!base)) { in event_base_foreach_event()
3811 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_foreach_event()
3812 r = event_base_foreach_event_nolock_(base, fn, arg); in event_base_foreach_event()
3813 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_foreach_event()
3819 event_base_dump_events(struct event_base *base, FILE *output) in event_base_dump_events() argument
3821 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_dump_events()
3823 event_base_foreach_event_nolock_(base, dump_inserted_event_fn, output); in event_base_dump_events()
3826 event_base_foreach_event_nolock_(base, dump_active_event_fn, output); in event_base_dump_events()
3827 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_dump_events()
3831 event_base_active_by_fd(struct event_base *base, evutil_socket_t fd, short events) in event_base_active_by_fd() argument
3833 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_active_by_fd()
3837 evmap_io_active_(base, fd, events & (EV_READ|EV_WRITE|EV_CLOSED)); in event_base_active_by_fd()
3845 for (u = 0; u < base->timeheap.n; ++u) { in event_base_active_by_fd()
3846 ev = base->timeheap.p[u]; in event_base_active_by_fd()
3852 for (i = 0; i < base->n_common_timeouts; ++i) { in event_base_active_by_fd()
3853 struct common_timeout_list *ctl = base->common_timeout_queues[i]; in event_base_active_by_fd()
3863 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_active_by_fd()
3867 event_base_active_by_signal(struct event_base *base, int sig) in event_base_active_by_signal() argument
3869 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_active_by_signal()
3870 evmap_signal_active_(base, sig, 1); in event_base_active_by_signal()
3871 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_active_by_signal()
3876 event_base_add_virtual_(struct event_base *base) in event_base_add_virtual_() argument
3878 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_add_virtual_()
3879 base->virtual_event_count++; in event_base_add_virtual_()
3880 MAX_EVENT_COUNT(base->virtual_event_count_max, base->virtual_event_count); in event_base_add_virtual_()
3881 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_add_virtual_()
3885 event_base_del_virtual_(struct event_base *base) in event_base_del_virtual_() argument
3887 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_del_virtual_()
3888 EVUTIL_ASSERT(base->virtual_event_count > 0); in event_base_del_virtual_()
3889 base->virtual_event_count--; in event_base_del_virtual_()
3890 if (base->virtual_event_count == 0 && EVBASE_NEED_NOTIFY(base)) in event_base_del_virtual_()
3891 evthread_notify_base(base); in event_base_del_virtual_()
3892 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_del_virtual_()
3961 event_base_assert_ok_(struct event_base *base) in event_base_assert_ok_() argument
3963 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_assert_ok_()
3964 event_base_assert_ok_nolock_(base); in event_base_assert_ok_()
3965 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_assert_ok_()
3969 event_base_assert_ok_nolock_(struct event_base *base) in event_base_assert_ok_nolock_() argument
3975 evmap_check_integrity_(base); in event_base_assert_ok_nolock_()
3978 for (i = 1; i < (int)base->timeheap.n; ++i) { in event_base_assert_ok_nolock_()
3981 ev = base->timeheap.p[i]; in event_base_assert_ok_nolock_()
3982 p_ev = base->timeheap.p[parent]; in event_base_assert_ok_nolock_()
3989 for (i = 0; i < base->n_common_timeouts; ++i) { in event_base_assert_ok_nolock_()
3990 struct common_timeout_list *ctl = base->common_timeout_queues[i]; in event_base_assert_ok_nolock_()
3999 EVUTIL_ASSERT(is_common_timeout(&ev->ev_timeout,base)); in event_base_assert_ok_nolock_()
4007 for (i = 0; i < base->nactivequeues; ++i) { in event_base_assert_ok_nolock_()
4009 EVUTIL_ASSERT_TAILQ_OK(&base->activequeues[i], event_callback, evcb_active_next); in event_base_assert_ok_nolock_()
4010 TAILQ_FOREACH(evcb, &base->activequeues[i], evcb_active_next) { in event_base_assert_ok_nolock_()
4019 TAILQ_FOREACH(evcb, &base->active_later_queue, evcb_active_next) { in event_base_assert_ok_nolock_()
4024 EVUTIL_ASSERT(count == base->event_count_active); in event_base_assert_ok_nolock_()