Lines Matching refs:base

144 static void event_queue_make_later_events_active(struct event_base *base);
146 static int evthread_make_base_notifiable_nolock_(struct event_base *base);
164 static int evthread_notify_base(struct event_base *base);
346 #define EVENT_BASE_ASSERT_LOCKED(base) \ argument
347 EVLOCK_ASSERT_LOCKED((base)->th_base_lock)
359 gettime(struct event_base *base, struct timeval *tp)
361 EVENT_BASE_ASSERT_LOCKED(base);
363 if (base->tv_cache.tv_sec) {
364 *tp = base->tv_cache;
368 if (evutil_gettime_monotonic_(&base->monotonic_timer, tp) == -1) {
372 if (base->last_updated_clock_diff + CLOCK_SYNC_INTERVAL
376 evutil_timersub(&tv, tp, &base->tv_clock_diff);
377 base->last_updated_clock_diff = tp->tv_sec;
384 event_base_gettimeofday_cached(struct event_base *base, struct timeval *tv) in event_base_gettimeofday_cached() argument
387 if (!base) { in event_base_gettimeofday_cached()
388 base = current_base; in event_base_gettimeofday_cached()
393 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_gettimeofday_cached()
394 if (base->tv_cache.tv_sec == 0) { in event_base_gettimeofday_cached()
397 evutil_timeradd(&base->tv_cache, &base->tv_clock_diff, tv); in event_base_gettimeofday_cached()
400 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_gettimeofday_cached()
406 clear_time_cache(struct event_base *base) in clear_time_cache() argument
408 base->tv_cache.tv_sec = 0; in clear_time_cache()
413 update_time_cache(struct event_base *base) in update_time_cache() argument
415 base->tv_cache.tv_sec = 0; in update_time_cache()
416 if (!(base->flags & EVENT_BASE_FLAG_NO_CACHE_TIME)) in update_time_cache()
417 gettime(base, &base->tv_cache); in update_time_cache()
421 event_base_update_cache_time(struct event_base *base) in event_base_update_cache_time() argument
424 if (!base) { in event_base_update_cache_time()
425 base = current_base; in event_base_update_cache_time()
430 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_update_cache_time()
431 if (base->running_loop) in event_base_update_cache_time()
432 update_time_cache(base); in event_base_update_cache_time()
433 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_update_cache_time()
453 struct event_base *base = event_base_new_with_config(NULL); in event_init() local
455 if (base == NULL) { in event_init()
460 current_base = base; in event_init()
462 return (base); in event_init()
468 struct event_base *base = NULL; in event_base_new() local
471 base = event_base_new_with_config(cfg); in event_base_new()
474 return base; in event_base_new()
510 event_base_get_features(const struct event_base *base) in event_base_get_features() argument
512 return base->evsel->features; in event_base_get_features()
554 struct event_base *base; in event_base_new_with_config() local
561 if ((base = mm_calloc(1, sizeof(struct event_base))) == NULL) { in event_base_new_with_config()
567 base->flags = cfg->flags; in event_base_new_with_config()
579 base->flags |= EVENT_BASE_FLAG_PRECISE_TIMER; in event_base_new_with_config()
582 evutil_configure_monotonic_time_(&base->monotonic_timer, flags); in event_base_new_with_config()
584 gettime(base, &tmp); in event_base_new_with_config()
587 min_heap_ctor_(&base->timeheap); in event_base_new_with_config()
589 base->sig.ev_signal_pair[0] = -1; in event_base_new_with_config()
590 base->sig.ev_signal_pair[1] = -1; in event_base_new_with_config()
591 base->th_notify_fd[0] = -1; in event_base_new_with_config()
592 base->th_notify_fd[1] = -1; in event_base_new_with_config()
594 TAILQ_INIT(&base->active_later_queue); in event_base_new_with_config()
596 evmap_io_initmap_(&base->io); in event_base_new_with_config()
597 evmap_signal_initmap_(&base->sigmap); in event_base_new_with_config()
598 event_changelist_init_(&base->changelist); in event_base_new_with_config()
600 base->evbase = NULL; in event_base_new_with_config()
603 memcpy(&base->max_dispatch_time, in event_base_new_with_config()
605 base->limit_callbacks_after_prio = in event_base_new_with_config()
608 base->max_dispatch_time.tv_sec = -1; in event_base_new_with_config()
609 base->limit_callbacks_after_prio = 1; in event_base_new_with_config()
612 base->max_dispatch_callbacks = cfg->max_dispatch_callbacks; in event_base_new_with_config()
614 base->max_dispatch_callbacks = INT_MAX; in event_base_new_with_config()
616 if (base->max_dispatch_callbacks == INT_MAX && in event_base_new_with_config()
617 base->max_dispatch_time.tv_sec == -1) in event_base_new_with_config()
618 base->limit_callbacks_after_prio = INT_MAX; in event_base_new_with_config()
620 for (i = 0; eventops[i] && !base->evbase; i++) { in event_base_new_with_config()
636 base->evsel = eventops[i]; in event_base_new_with_config()
638 base->evbase = base->evsel->init(base); in event_base_new_with_config()
641 if (base->evbase == NULL) { in event_base_new_with_config()
644 base->evsel = NULL; in event_base_new_with_config()
645 event_base_free(base); in event_base_new_with_config()
650 event_msgx("libevent using: %s", base->evsel->name); in event_base_new_with_config()
653 if (event_base_priority_init(base, 1) < 0) { in event_base_new_with_config()
654 event_base_free(base); in event_base_new_with_config()
664 EVTHREAD_ALLOC_LOCK(base->th_base_lock, 0); in event_base_new_with_config()
665 EVTHREAD_ALLOC_COND(base->current_event_cond); in event_base_new_with_config()
666 r = evthread_make_base_notifiable(base); in event_base_new_with_config()
669 event_base_free(base); in event_base_new_with_config()
677 event_base_start_iocp_(base, cfg->n_cpus_hint); in event_base_new_with_config()
680 return (base); in event_base_new_with_config()
684 event_base_start_iocp_(struct event_base *base, int n_cpus) in event_base_start_iocp_() argument
687 if (base->iocp) in event_base_start_iocp_()
689 base->iocp = event_iocp_port_launch_(n_cpus); in event_base_start_iocp_()
690 if (!base->iocp) { in event_base_start_iocp_()
701 event_base_stop_iocp_(struct event_base *base) in event_base_stop_iocp_() argument
706 if (!base->iocp) in event_base_stop_iocp_()
708 rv = event_iocp_shutdown_(base->iocp, -1); in event_base_stop_iocp_()
710 base->iocp = NULL; in event_base_stop_iocp_()
715 event_base_cancel_single_callback_(struct event_base *base, in event_base_cancel_single_callback_() argument
728 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_cancel_single_callback_()
729 event_callback_cancel_nolock_(base, evcb, 1); in event_base_cancel_single_callback_()
730 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_cancel_single_callback_()
755 event_base_free_(struct event_base *base, int run_finalizers) in event_base_free_() argument
764 if (base == NULL && current_base) in event_base_free_()
765 base = current_base; in event_base_free_()
767 if (base == NULL) { in event_base_free_()
774 event_base_stop_iocp_(base); in event_base_free_()
778 if (base->th_notify_fd[0] != -1) { in event_base_free_()
779 event_del(&base->th_notify); in event_base_free_()
780 EVUTIL_CLOSESOCKET(base->th_notify_fd[0]); in event_base_free_()
781 if (base->th_notify_fd[1] != -1) in event_base_free_()
782 EVUTIL_CLOSESOCKET(base->th_notify_fd[1]); in event_base_free_()
783 base->th_notify_fd[0] = -1; in event_base_free_()
784 base->th_notify_fd[1] = -1; in event_base_free_()
785 event_debug_unassign(&base->th_notify); in event_base_free_()
789 evmap_delete_all_(base); in event_base_free_()
791 while ((ev = min_heap_top_(&base->timeheap)) != NULL) { in event_base_free_()
795 for (i = 0; i < base->n_common_timeouts; ++i) { in event_base_free_()
797 base->common_timeout_queues[i]; in event_base_free_()
811 if (base->common_timeout_queues) in event_base_free_()
812 mm_free(base->common_timeout_queues); in event_base_free_()
814 for (i = 0; i < base->nactivequeues; ++i) { in event_base_free_()
816 for (evcb = TAILQ_FIRST(&base->activequeues[i]); evcb; ) { in event_base_free_()
818 n_deleted += event_base_cancel_single_callback_(base, evcb, run_finalizers); in event_base_free_()
824 while ((evcb = TAILQ_FIRST(&base->active_later_queue))) { in event_base_free_()
825 n_deleted += event_base_cancel_single_callback_(base, evcb, run_finalizers); in event_base_free_()
834 while (LIST_FIRST(&base->once_events)) { in event_base_free_()
835 struct event_once *eonce = LIST_FIRST(&base->once_events); in event_base_free_()
840 if (base->evsel != NULL && base->evsel->dealloc != NULL) in event_base_free_()
841 base->evsel->dealloc(base); in event_base_free_()
843 for (i = 0; i < base->nactivequeues; ++i) in event_base_free_()
844 EVUTIL_ASSERT(TAILQ_EMPTY(&base->activequeues[i])); in event_base_free_()
846 EVUTIL_ASSERT(min_heap_empty_(&base->timeheap)); in event_base_free_()
847 min_heap_dtor_(&base->timeheap); in event_base_free_()
849 mm_free(base->activequeues); in event_base_free_()
851 evmap_io_clear_(&base->io); in event_base_free_()
852 evmap_signal_clear_(&base->sigmap); in event_base_free_()
853 event_changelist_freemem_(&base->changelist); in event_base_free_()
855 EVTHREAD_FREE_LOCK(base->th_base_lock, 0); in event_base_free_()
856 EVTHREAD_FREE_COND(base->current_event_cond); in event_base_free_()
859 if (base == current_base) in event_base_free_()
861 mm_free(base); in event_base_free_()
865 event_base_free_nofinalize(struct event_base *base) in event_base_free_nofinalize() argument
867 event_base_free_(base, 0); in event_base_free_nofinalize()
871 event_base_free(struct event_base *base) in event_base_free() argument
873 event_base_free_(base, 1); in event_base_free()
897 event_reinit(struct event_base *base) in event_reinit() argument
904 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_reinit()
906 evsel = base->evsel; in event_reinit()
918 base->evsel = &nil_eventop; in event_reinit()
927 if (base->sig.ev_signal_added) { in event_reinit()
928 event_del_nolock_(&base->sig.ev_signal, EVENT_DEL_AUTOBLOCK); in event_reinit()
929 event_debug_unassign(&base->sig.ev_signal); in event_reinit()
930 memset(&base->sig.ev_signal, 0, sizeof(base->sig.ev_signal)); in event_reinit()
931 if (base->sig.ev_signal_pair[0] != -1) in event_reinit()
932 EVUTIL_CLOSESOCKET(base->sig.ev_signal_pair[0]); in event_reinit()
933 if (base->sig.ev_signal_pair[1] != -1) in event_reinit()
934 EVUTIL_CLOSESOCKET(base->sig.ev_signal_pair[1]); in event_reinit()
936 base->sig.ev_signal_added = 0; in event_reinit()
938 if (base->th_notify_fn != NULL) { in event_reinit()
940 base->th_notify_fn = NULL; in event_reinit()
942 if (base->th_notify_fd[0] != -1) { in event_reinit()
943 event_del_nolock_(&base->th_notify, EVENT_DEL_AUTOBLOCK); in event_reinit()
944 EVUTIL_CLOSESOCKET(base->th_notify_fd[0]); in event_reinit()
945 if (base->th_notify_fd[1] != -1) in event_reinit()
946 EVUTIL_CLOSESOCKET(base->th_notify_fd[1]); in event_reinit()
947 base->th_notify_fd[0] = -1; in event_reinit()
948 base->th_notify_fd[1] = -1; in event_reinit()
949 event_debug_unassign(&base->th_notify); in event_reinit()
953 base->evsel = evsel; in event_reinit()
965 if (base->evsel->dealloc != NULL) in event_reinit()
966 base->evsel->dealloc(base); in event_reinit()
967 base->evbase = evsel->init(base); in event_reinit()
968 if (base->evbase == NULL) { in event_reinit()
978 event_changelist_freemem_(&base->changelist); in event_reinit()
983 if (evmap_reinit_(base) < 0) in event_reinit()
987 res = evsig_init_(base); in event_reinit()
993 res = evthread_make_base_notifiable_nolock_(base); in event_reinit()
996 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_reinit()
1002 event_gettime_monotonic(struct event_base *base, struct timeval *tv) in event_gettime_monotonic() argument
1006 if (base && tv) { in event_gettime_monotonic()
1007 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_gettime_monotonic()
1008 rv = evutil_gettime_monotonic_(&(base->monotonic_timer), tv); in event_gettime_monotonic()
1009 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_gettime_monotonic()
1152 event_base_priority_init(struct event_base *base, int npriorities) in event_base_priority_init() argument
1157 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_priority_init()
1159 if (N_ACTIVE_CALLBACKS(base) || npriorities < 1 in event_base_priority_init()
1163 if (npriorities == base->nactivequeues) in event_base_priority_init()
1166 if (base->nactivequeues) { in event_base_priority_init()
1167 mm_free(base->activequeues); in event_base_priority_init()
1168 base->nactivequeues = 0; in event_base_priority_init()
1172 base->activequeues = (struct evcallback_list *) in event_base_priority_init()
1174 if (base->activequeues == NULL) { in event_base_priority_init()
1178 base->nactivequeues = npriorities; in event_base_priority_init()
1180 for (i = 0; i < base->nactivequeues; ++i) { in event_base_priority_init()
1181 TAILQ_INIT(&base->activequeues[i]); in event_base_priority_init()
1187 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_priority_init()
1192 event_base_get_npriorities(struct event_base *base) in event_base_get_npriorities() argument
1196 if (base == NULL) in event_base_get_npriorities()
1197 base = current_base; in event_base_get_npriorities()
1199 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_get_npriorities()
1200 n = base->nactivequeues; in event_base_get_npriorities()
1201 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_get_npriorities()
1206 event_base_get_num_events(struct event_base *base, unsigned int type) in event_base_get_num_events() argument
1210 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_get_num_events()
1213 r += base->event_count_active; in event_base_get_num_events()
1216 r += base->virtual_event_count; in event_base_get_num_events()
1219 r += base->event_count; in event_base_get_num_events()
1221 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_get_num_events()
1227 event_base_get_max_events(struct event_base *base, unsigned int type, int clear) in event_base_get_max_events() argument
1231 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_get_max_events()
1234 r += base->event_count_active_max; in event_base_get_max_events()
1236 base->event_count_active_max = 0; in event_base_get_max_events()
1240 r += base->virtual_event_count_max; in event_base_get_max_events()
1242 base->virtual_event_count_max = 0; in event_base_get_max_events()
1246 r += base->event_count_max; in event_base_get_max_events()
1248 base->event_count_max = 0; in event_base_get_max_events()
1251 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_get_max_events()
1258 event_haveevents(struct event_base *base) in event_haveevents() argument
1261 return (base->virtual_event_count > 0 || base->event_count > 0); in event_haveevents()
1266 event_signal_closure(struct event_base *base, struct event *ev) in event_signal_closure() argument
1275 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_signal_closure()
1283 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_signal_closure()
1284 should_break = base->event_break; in event_signal_closure()
1285 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_signal_closure()
1321 const struct event_base *base) in is_common_timeout() argument
1327 return idx < base->n_common_timeouts; in is_common_timeout()
1342 get_common_timeout_list(struct event_base *base, const struct timeval *tv) in get_common_timeout_list() argument
1344 return base->common_timeout_queues[COMMON_TIMEOUT_IDX(tv)]; in get_common_timeout_list()
1350 struct event_base *base)
1353 &get_common_timeout_list(base, tv)->duration;
1378 struct event_base *base = ctl->base; in common_timeout_callback() local
1380 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in common_timeout_callback()
1381 gettime(base, &now); in common_timeout_callback()
1393 EVBASE_RELEASE_LOCK(base, th_base_lock); in common_timeout_callback()
1399 event_base_init_common_timeout(struct event_base *base, in event_base_init_common_timeout() argument
1407 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_init_common_timeout()
1410 if (is_common_timeout(duration, base)) in event_base_init_common_timeout()
1416 for (i = 0; i < base->n_common_timeouts; ++i) { in event_base_init_common_timeout()
1418 base->common_timeout_queues[i]; in event_base_init_common_timeout()
1422 EVUTIL_ASSERT(is_common_timeout(&ctl->duration, base)); in event_base_init_common_timeout()
1427 if (base->n_common_timeouts == MAX_COMMON_TIMEOUTS) { in event_base_init_common_timeout()
1433 if (base->n_common_timeouts_allocated == base->n_common_timeouts) { in event_base_init_common_timeout()
1434 int n = base->n_common_timeouts < 16 ? 16 : in event_base_init_common_timeout()
1435 base->n_common_timeouts*2; in event_base_init_common_timeout()
1437 mm_realloc(base->common_timeout_queues, in event_base_init_common_timeout()
1443 base->n_common_timeouts_allocated = n; in event_base_init_common_timeout()
1444 base->common_timeout_queues = newqueues; in event_base_init_common_timeout()
1455 (base->n_common_timeouts << COMMON_TIMEOUT_IDX_SHIFT); in event_base_init_common_timeout()
1456 evtimer_assign(&new_ctl->timeout_event, base, in event_base_init_common_timeout()
1460 new_ctl->base = base; in event_base_init_common_timeout()
1461 base->common_timeout_queues[base->n_common_timeouts++] = new_ctl; in event_base_init_common_timeout()
1466 EVUTIL_ASSERT(is_common_timeout(result, base)); in event_base_init_common_timeout()
1468 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_init_common_timeout()
1474 event_persist_closure(struct event_base *base, struct event *ev) in event_persist_closure() argument
1493 gettime(base, &now); in event_persist_closure()
1494 if (is_common_timeout(&ev->ev_timeout, base)) { in event_persist_closure()
1532 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_persist_closure()
1546 event_process_active_single_queue(struct event_base *base, in event_process_active_single_queue() argument
1561 event_queue_remove_active(base, evcb); in event_process_active_single_queue()
1572 event_queue_remove_active(base, evcb); in event_process_active_single_queue()
1582 base->current_event = evcb; in event_process_active_single_queue()
1584 base->current_event_waiters = 0; in event_process_active_single_queue()
1590 event_signal_closure(base, ev); in event_process_active_single_queue()
1594 event_persist_closure(base, ev); in event_process_active_single_queue()
1600 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_process_active_single_queue()
1606 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_process_active_single_queue()
1615 base->current_event = NULL; in event_process_active_single_queue()
1618 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_process_active_single_queue()
1627 base->current_event = NULL; in event_process_active_single_queue()
1629 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_process_active_single_queue()
1637 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_process_active_single_queue()
1638 base->current_event = NULL; in event_process_active_single_queue()
1640 if (base->current_event_waiters) { in event_process_active_single_queue()
1641 base->current_event_waiters = 0; in event_process_active_single_queue()
1642 EVTHREAD_COND_BROADCAST(base->current_event_cond); in event_process_active_single_queue()
1646 if (base->event_break) in event_process_active_single_queue()
1652 update_time_cache(base); in event_process_active_single_queue()
1653 gettime(base, &now); in event_process_active_single_queue()
1657 if (base->event_continue) in event_process_active_single_queue()
1670 event_process_active(struct event_base *base) in event_process_active() argument
1677 const int maxcb = base->max_dispatch_callbacks; in event_process_active()
1678 const int limit_after_prio = base->limit_callbacks_after_prio; in event_process_active()
1679 if (base->max_dispatch_time.tv_sec >= 0) { in event_process_active()
1680 update_time_cache(base); in event_process_active()
1681 gettime(base, &tv); in event_process_active()
1682 evutil_timeradd(&base->max_dispatch_time, &tv, &tv); in event_process_active()
1688 for (i = 0; i < base->nactivequeues; ++i) { in event_process_active()
1689 if (TAILQ_FIRST(&base->activequeues[i]) != NULL) { in event_process_active()
1690 base->event_running_priority = i; in event_process_active()
1691 activeq = &base->activequeues[i]; in event_process_active()
1693 c = event_process_active_single_queue(base, activeq, in event_process_active()
1696 c = event_process_active_single_queue(base, activeq, in event_process_active()
1709 base->event_running_priority = -1; in event_process_active()
1731 event_base_get_method(const struct event_base *base) in event_base_get_method() argument
1733 EVUTIL_ASSERT(base); in event_base_get_method()
1734 return (base->evsel->name); in event_base_get_method()
1742 struct event_base *base = arg; in event_loopexit_cb() local
1743 base->event_gotterm = 1; in event_loopexit_cb()
1833 event_base_loop(struct event_base *base, int flags) in event_base_loop() argument
1835 const struct eventop *evsel = base->evsel; in event_base_loop()
1842 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_loop()
1844 if (base->running_loop) { in event_base_loop()
1847 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_loop()
1851 base->running_loop = 1; in event_base_loop()
1853 clear_time_cache(base); in event_base_loop()
1855 if (base->sig.ev_signal_added && base->sig.ev_n_signals_added) in event_base_loop()
1856 evsig_set_base_(base); in event_base_loop()
1861 base->th_owner_id = EVTHREAD_GET_ID(); in event_base_loop()
1864 base->event_gotterm = base->event_break = 0; in event_base_loop()
1867 base->event_continue = 0; in event_base_loop()
1868 base->n_deferreds_queued = 0; in event_base_loop()
1871 if (base->event_gotterm) { in event_base_loop()
1875 if (base->event_break) { in event_base_loop()
1880 if (!N_ACTIVE_CALLBACKS(base) && !(flags & EVLOOP_NONBLOCK)) { in event_base_loop()
1881 timeout_next(base, &tv_p); in event_base_loop()
1892 !event_haveevents(base) && !N_ACTIVE_CALLBACKS(base)) { in event_base_loop()
1898 event_queue_make_later_events_active(base); in event_base_loop()
1900 clear_time_cache(base); in event_base_loop()
1902 res = evsel->dispatch(base, tv_p); in event_base_loop()
1911 update_time_cache(base); in event_base_loop()
1913 timeout_process(base); in event_base_loop()
1915 if (N_ACTIVE_CALLBACKS(base)) { in event_base_loop()
1916 int n = event_process_active(base); in event_base_loop()
1918 && N_ACTIVE_CALLBACKS(base) == 0 in event_base_loop()
1927 clear_time_cache(base); in event_base_loop()
1928 base->running_loop = 0; in event_base_loop()
1930 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_loop()
1961 event_base_once(struct event_base *base, evutil_socket_t fd, short events, in event_base_once() argument
1981 evtimer_assign(&eonce->ev, base, event_once_cb, eonce); in event_base_once()
1993 event_assign(&eonce->ev, base, fd, events, event_once_cb, eonce); in event_base_once()
2001 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_once()
2011 LIST_INSERT_HEAD(&base->once_events, eonce, next_once); in event_base_once()
2013 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_once()
2020 event_assign(struct event *ev, struct event_base *base, evutil_socket_t fd, short events, void (*ca… in event_assign() argument
2022 if (!base) in event_assign()
2023 base = current_base; in event_assign()
2029 ev->ev_base = base; in event_assign()
2058 if (base != NULL) { in event_assign()
2060 ev->ev_pri = base->nactivequeues / 2; in event_assign()
2069 event_base_set(struct event_base *base, struct event *ev) in event_base_set() argument
2077 ev->ev_base = base; in event_base_set()
2078 ev->ev_pri = base->nactivequeues/2; in event_base_set()
2099 event_base_get_running_event(struct event_base *base) in event_base_get_running_event() argument
2102 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_get_running_event()
2103 if (EVBASE_IN_THREAD(base)) { in event_base_get_running_event()
2104 struct event_callback *evcb = base->current_event; in event_base_get_running_event()
2108 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_get_running_event()
2113 event_new(struct event_base *base, evutil_socket_t fd, short events, void (*cb)(evutil_socket_t, sh… in event_new() argument
2119 if (event_assign(ev, base, fd, events, cb, arg) < 0) { in event_new()
2152 event_finalize_nolock_(struct event_base *base, unsigned flags, struct event *ev, event_finalize_ca… in event_finalize_nolock_() argument
2169 struct event_base *base = ev->ev_base; in event_finalize_impl_() local
2170 if (EVUTIL_FAILURE_CHECK(!base)) { in event_finalize_impl_()
2175 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_finalize_impl_()
2176 r = event_finalize_nolock_(base, flags, ev, cb); in event_finalize_impl_()
2177 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_finalize_impl_()
2194 event_callback_finalize_nolock_(struct event_base *base, unsigned flags, struct event_callback *evc… in event_callback_finalize_nolock_() argument
2201 event_callback_cancel_nolock_(base, evcb, 0); /*XXX can this fail?*/ in event_callback_finalize_nolock_()
2206 event_callback_activate_nolock_(base, evcb); /* XXX can this really fail?*/ in event_callback_finalize_nolock_()
2211 event_callback_finalize_(struct event_base *base, unsigned flags, struct event_callback *evcb, void… in event_callback_finalize_() argument
2213 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_callback_finalize_()
2214 event_callback_finalize_nolock_(base, flags, evcb, cb); in event_callback_finalize_()
2215 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_callback_finalize_()
2222 event_callback_finalize_many_(struct event_base *base, int n_cbs, struct event_callback **evcbs, vo… in event_callback_finalize_many_() argument
2226 if (base == NULL) in event_callback_finalize_many_()
2227 base = current_base; in event_callback_finalize_many_()
2229 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_callback_finalize_many_()
2238 if (evcb == base->current_event) { in event_callback_finalize_many_()
2239 event_callback_finalize_nolock_(base, 0, evcb, cb); in event_callback_finalize_many_()
2242 event_callback_cancel_nolock_(base, evcb, 0); in event_callback_finalize_many_()
2248 event_callback_finalize_nolock_(base, 0, evcbs[0], cb); in event_callback_finalize_many_()
2251 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_callback_finalize_many_()
2412 evthread_notify_base_default(struct event_base *base) in evthread_notify_base_default() argument
2418 r = send(base->th_notify_fd[1], buf, 1, 0); in evthread_notify_base_default()
2420 r = write(base->th_notify_fd[1], buf, 1); in evthread_notify_base_default()
2429 evthread_notify_base_eventfd(struct event_base *base) in evthread_notify_base_eventfd() argument
2434 r = write(base->th_notify_fd[0], (void*) &msg, sizeof(msg)); in evthread_notify_base_eventfd()
2446 evthread_notify_base(struct event_base *base) in evthread_notify_base() argument
2448 EVENT_BASE_ASSERT_LOCKED(base); in evthread_notify_base()
2449 if (!base->th_notify_fn) in evthread_notify_base()
2451 if (base->is_notify_pending) in evthread_notify_base()
2453 base->is_notify_pending = 1; in evthread_notify_base()
2454 return base->th_notify_fn(base); in evthread_notify_base()
2462 struct event_base *base = ev->ev_base; in event_remove_timer_nolock_() local
2464 EVENT_BASE_ASSERT_LOCKED(base); in event_remove_timer_nolock_()
2471 event_queue_remove_timeout(base, ev); in event_remove_timer_nolock_()
2505 struct event_base *base = ev->ev_base; in event_add_nolock_() local
2509 EVENT_BASE_ASSERT_LOCKED(base); in event_add_nolock_()
2534 if (min_heap_reserve_(&base->timeheap, in event_add_nolock_()
2535 1 + min_heap_size_(&base->timeheap)) == -1) in event_add_nolock_()
2544 if (base->current_event == event_to_event_callback(ev) && in event_add_nolock_()
2546 && !EVBASE_IN_THREAD(base)) { in event_add_nolock_()
2547 ++base->current_event_waiters; in event_add_nolock_()
2548 EVTHREAD_COND_WAIT(base->current_event_cond, base->th_base_lock); in event_add_nolock_()
2555 res = evmap_io_add_(base, ev->ev_fd, ev); in event_add_nolock_()
2557 res = evmap_signal_add_(base, (int)ev->ev_fd, ev); in event_add_nolock_()
2559 event_queue_insert_inserted(base, ev); in event_add_nolock_()
2590 event_queue_remove_timeout(base, ev); in event_add_nolock_()
2609 event_queue_remove_active(base, event_to_event_callback(ev)); in event_add_nolock_()
2612 gettime(base, &now); in event_add_nolock_()
2614 common_timeout = is_common_timeout(tv, base); in event_add_nolock_()
2616 was_common = is_common_timeout(&ev->ev_timeout, base); in event_add_nolock_()
2637 event_queue_reinsert_timeout(base, ev, was_common, common_timeout, old_timeout_idx); in event_add_nolock_()
2639 event_queue_insert_timeout(base, ev); in event_add_nolock_()
2644 get_common_timeout_list(base, &ev->ev_timeout); in event_add_nolock_()
2658 else if ((top = min_heap_top_(&base->timeheap)) != NULL && in event_add_nolock_()
2665 if (res != -1 && notify && EVBASE_NEED_NOTIFY(base)) in event_add_nolock_()
2666 evthread_notify_base(base); in event_add_nolock_()
2718 struct event_base *base; in event_del_nolock_() local
2742 base = ev->ev_base; in event_del_nolock_()
2745 base->current_event == event_to_event_callback(ev) && in event_del_nolock_()
2746 !EVBASE_IN_THREAD(base) && in event_del_nolock_()
2748 ++base->current_event_waiters; in event_del_nolock_()
2749 EVTHREAD_COND_WAIT(base->current_event_cond, base->th_base_lock); in event_del_nolock_()
2771 event_queue_remove_timeout(base, ev); in event_del_nolock_()
2775 event_queue_remove_active(base, event_to_event_callback(ev)); in event_del_nolock_()
2777 event_queue_remove_active_later(base, event_to_event_callback(ev)); in event_del_nolock_()
2780 event_queue_remove_inserted(base, ev); in event_del_nolock_()
2782 res = evmap_io_del_(base, ev->ev_fd, ev); in event_del_nolock_()
2784 res = evmap_signal_del_(base, (int)ev->ev_fd, ev); in event_del_nolock_()
2793 if (res != -1 && notify && EVBASE_NEED_NOTIFY(base)) in event_del_nolock_()
2794 evthread_notify_base(base); in event_del_nolock_()
2822 struct event_base *base; in event_active_nolock_() local
2827 base = ev->ev_base; in event_active_nolock_()
2828 EVENT_BASE_ASSERT_LOCKED(base); in event_active_nolock_()
2852 if (ev->ev_pri < base->event_running_priority) in event_active_nolock_()
2853 base->event_continue = 1; in event_active_nolock_()
2857 if (base->current_event == event_to_event_callback(ev) && in event_active_nolock_()
2858 !EVBASE_IN_THREAD(base)) { in event_active_nolock_()
2859 ++base->current_event_waiters; in event_active_nolock_()
2860 EVTHREAD_COND_WAIT(base->current_event_cond, base->th_base_lock); in event_active_nolock_()
2867 event_callback_activate_nolock_(base, event_to_event_callback(ev)); in event_active_nolock_()
2881 struct event_base *base = ev->ev_base; in event_active_later_nolock_() local
2882 EVENT_BASE_ASSERT_LOCKED(base); in event_active_later_nolock_()
2892 event_callback_activate_later_nolock_(base, event_to_event_callback(ev)); in event_active_later_nolock_()
2896 event_callback_activate_(struct event_base *base, in event_callback_activate_() argument
2900 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_callback_activate_()
2901 r = event_callback_activate_nolock_(base, evcb); in event_callback_activate_()
2902 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_callback_activate_()
2907 event_callback_activate_nolock_(struct event_base *base, in event_callback_activate_nolock_() argument
2919 event_queue_remove_active_later(base, evcb); in event_callback_activate_nolock_()
2928 event_queue_insert_active(base, evcb); in event_callback_activate_nolock_()
2930 if (EVBASE_NEED_NOTIFY(base)) in event_callback_activate_nolock_()
2931 evthread_notify_base(base); in event_callback_activate_nolock_()
2937 event_callback_activate_later_nolock_(struct event_base *base, in event_callback_activate_later_nolock_() argument
2943 event_queue_insert_active_later(base, evcb); in event_callback_activate_later_nolock_()
2944 if (EVBASE_NEED_NOTIFY(base)) in event_callback_activate_later_nolock_()
2945 evthread_notify_base(base); in event_callback_activate_later_nolock_()
2949 event_callback_init_(struct event_base *base, in event_callback_init_() argument
2953 cb->evcb_pri = base->nactivequeues - 1; in event_callback_init_()
2957 event_callback_cancel_(struct event_base *base, in event_callback_cancel_() argument
2961 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_callback_cancel_()
2962 r = event_callback_cancel_nolock_(base, evcb, 0); in event_callback_cancel_()
2963 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_callback_cancel_()
2968 event_callback_cancel_nolock_(struct event_base *base, in event_callback_cancel_nolock_() argument
2985 event_queue_remove_active(base, evcb); in event_callback_cancel_nolock_()
2988 event_queue_remove_active_later(base, evcb); in event_callback_cancel_nolock_()
3014 event_deferred_cb_cancel_(struct event_base *base, struct event_callback *cb) in event_deferred_cb_cancel_() argument
3016 if (!base) in event_deferred_cb_cancel_()
3017 base = current_base; in event_deferred_cb_cancel_()
3018 event_callback_cancel_(base, cb); in event_deferred_cb_cancel_()
3023 event_deferred_cb_schedule_(struct event_base *base, struct event_callback *cb) in event_deferred_cb_schedule_() argument
3026 if (!base) in event_deferred_cb_schedule_()
3027 base = current_base; in event_deferred_cb_schedule_()
3028 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_deferred_cb_schedule_()
3029 if (base->n_deferreds_queued > MAX_DEFERREDS_QUEUED) { in event_deferred_cb_schedule_()
3030 event_callback_activate_later_nolock_(base, cb); in event_deferred_cb_schedule_()
3032 ++base->n_deferreds_queued; in event_deferred_cb_schedule_()
3033 r = event_callback_activate_nolock_(base, cb); in event_deferred_cb_schedule_()
3035 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_deferred_cb_schedule_()
3040 timeout_next(struct event_base *base, struct timeval **tv_p) in timeout_next() argument
3048 ev = min_heap_top_(&base->timeheap); in timeout_next()
3056 if (gettime(base, &now) == -1) { in timeout_next()
3078 timeout_process(struct event_base *base) in timeout_process() argument
3084 if (min_heap_empty_(&base->timeheap)) { in timeout_process()
3088 gettime(base, &now); in timeout_process()
3090 while ((ev = min_heap_top_(&base->timeheap))) { in timeout_process()
3117 #define DECR_EVENT_COUNT(base,flags) \ argument
3118 ((base)->event_count -= (~((flags) >> 4) & 1))
3119 #define INCR_EVENT_COUNT(base,flags) do { \ argument
3120 ((base)->event_count += (~((flags) >> 4) & 1)); \
3121 MAX_EVENT_COUNT((base)->event_count_max, (base)->event_count); \
3125 event_queue_remove_inserted(struct event_base *base, struct event *ev) in event_queue_remove_inserted() argument
3127 EVENT_BASE_ASSERT_LOCKED(base); in event_queue_remove_inserted()
3133 DECR_EVENT_COUNT(base, ev->ev_flags); in event_queue_remove_inserted()
3137 event_queue_remove_active(struct event_base *base, struct event_callback *evcb) in event_queue_remove_active() argument
3139 EVENT_BASE_ASSERT_LOCKED(base); in event_queue_remove_active()
3145 DECR_EVENT_COUNT(base, evcb->evcb_flags); in event_queue_remove_active()
3147 base->event_count_active--; in event_queue_remove_active()
3149 TAILQ_REMOVE(&base->activequeues[evcb->evcb_pri], in event_queue_remove_active()
3153 event_queue_remove_active_later(struct event_base *base, struct event_callback *evcb) in event_queue_remove_active_later() argument
3155 EVENT_BASE_ASSERT_LOCKED(base); in event_queue_remove_active_later()
3161 DECR_EVENT_COUNT(base, evcb->evcb_flags); in event_queue_remove_active_later()
3163 base->event_count_active--; in event_queue_remove_active_later()
3165 TAILQ_REMOVE(&base->active_later_queue, evcb, evcb_active_next); in event_queue_remove_active_later()
3168 event_queue_remove_timeout(struct event_base *base, struct event *ev) in event_queue_remove_timeout() argument
3170 EVENT_BASE_ASSERT_LOCKED(base); in event_queue_remove_timeout()
3176 DECR_EVENT_COUNT(base, ev->ev_flags); in event_queue_remove_timeout()
3179 if (is_common_timeout(&ev->ev_timeout, base)) { in event_queue_remove_timeout()
3181 get_common_timeout_list(base, &ev->ev_timeout); in event_queue_remove_timeout()
3185 min_heap_erase_(&base->timeheap, ev); in event_queue_remove_timeout()
3192 event_queue_reinsert_timeout(struct event_base *base, struct event *ev, in event_queue_reinsert_timeout() argument
3197 event_queue_insert_timeout(base, ev); in event_queue_reinsert_timeout()
3203 ctl = base->common_timeout_queues[old_timeout_idx]; in event_queue_reinsert_timeout()
3206 ctl = get_common_timeout_list(base, &ev->ev_timeout); in event_queue_reinsert_timeout()
3210 ctl = base->common_timeout_queues[old_timeout_idx]; in event_queue_reinsert_timeout()
3213 min_heap_push_(&base->timeheap, ev); in event_queue_reinsert_timeout()
3216 min_heap_erase_(&base->timeheap, ev); in event_queue_reinsert_timeout()
3217 ctl = get_common_timeout_list(base, &ev->ev_timeout); in event_queue_reinsert_timeout()
3221 min_heap_adjust_(&base->timeheap, ev); in event_queue_reinsert_timeout()
3262 event_queue_insert_inserted(struct event_base *base, struct event *ev) in event_queue_insert_inserted() argument
3264 EVENT_BASE_ASSERT_LOCKED(base); in event_queue_insert_inserted()
3272 INCR_EVENT_COUNT(base, ev->ev_flags); in event_queue_insert_inserted()
3278 event_queue_insert_active(struct event_base *base, struct event_callback *evcb) in event_queue_insert_active() argument
3280 EVENT_BASE_ASSERT_LOCKED(base); in event_queue_insert_active()
3287 INCR_EVENT_COUNT(base, evcb->evcb_flags); in event_queue_insert_active()
3291 base->event_count_active++; in event_queue_insert_active()
3292 MAX_EVENT_COUNT(base->event_count_active_max, base->event_count_active); in event_queue_insert_active()
3293 EVUTIL_ASSERT(evcb->evcb_pri < base->nactivequeues); in event_queue_insert_active()
3294 TAILQ_INSERT_TAIL(&base->activequeues[evcb->evcb_pri], in event_queue_insert_active()
3299 event_queue_insert_active_later(struct event_base *base, struct event_callback *evcb) in event_queue_insert_active_later() argument
3301 EVENT_BASE_ASSERT_LOCKED(base); in event_queue_insert_active_later()
3307 INCR_EVENT_COUNT(base, evcb->evcb_flags); in event_queue_insert_active_later()
3309 base->event_count_active++; in event_queue_insert_active_later()
3310 MAX_EVENT_COUNT(base->event_count_active_max, base->event_count_active); in event_queue_insert_active_later()
3311 EVUTIL_ASSERT(evcb->evcb_pri < base->nactivequeues); in event_queue_insert_active_later()
3312 TAILQ_INSERT_TAIL(&base->active_later_queue, evcb, evcb_active_next); in event_queue_insert_active_later()
3316 event_queue_insert_timeout(struct event_base *base, struct event *ev) in event_queue_insert_timeout() argument
3318 EVENT_BASE_ASSERT_LOCKED(base); in event_queue_insert_timeout()
3326 INCR_EVENT_COUNT(base, ev->ev_flags); in event_queue_insert_timeout()
3330 if (is_common_timeout(&ev->ev_timeout, base)) { in event_queue_insert_timeout()
3332 get_common_timeout_list(base, &ev->ev_timeout); in event_queue_insert_timeout()
3335 min_heap_push_(&base->timeheap, ev); in event_queue_insert_timeout()
3340 event_queue_make_later_events_active(struct event_base *base) in event_queue_make_later_events_active() argument
3343 EVENT_BASE_ASSERT_LOCKED(base); in event_queue_make_later_events_active()
3345 while ((evcb = TAILQ_FIRST(&base->active_later_queue))) { in event_queue_make_later_events_active()
3346 TAILQ_REMOVE(&base->active_later_queue, evcb, evcb_active_next); in event_queue_make_later_events_active()
3348 EVUTIL_ASSERT(evcb->evcb_pri < base->nactivequeues); in event_queue_make_later_events_active()
3349 TAILQ_INSERT_TAIL(&base->activequeues[evcb->evcb_pri], evcb, evcb_active_next); in event_queue_make_later_events_active()
3350 base->n_deferreds_queued += (evcb->evcb_closure == EV_CLOSURE_CB_SELF); in event_queue_make_later_events_active()
3488 struct event_base *base = arg; in evthread_notify_drain_eventfd() local
3494 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in evthread_notify_drain_eventfd()
3495 base->is_notify_pending = 0; in evthread_notify_drain_eventfd()
3496 EVBASE_RELEASE_LOCK(base, th_base_lock); in evthread_notify_drain_eventfd()
3504 struct event_base *base = arg; in evthread_notify_drain_default() local
3513 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in evthread_notify_drain_default()
3514 base->is_notify_pending = 0; in evthread_notify_drain_default()
3515 EVBASE_RELEASE_LOCK(base, th_base_lock); in evthread_notify_drain_default()
3519 evthread_make_base_notifiable(struct event_base *base) in evthread_make_base_notifiable() argument
3522 if (!base) in evthread_make_base_notifiable()
3525 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in evthread_make_base_notifiable()
3526 r = evthread_make_base_notifiable_nolock_(base); in evthread_make_base_notifiable()
3527 EVBASE_RELEASE_LOCK(base, th_base_lock); in evthread_make_base_notifiable()
3532 evthread_make_base_notifiable_nolock_(struct event_base *base) in evthread_make_base_notifiable_nolock_() argument
3537 if (base->th_notify_fn != NULL) { in evthread_make_base_notifiable_nolock_()
3543 if (base->evsel == &kqops && event_kq_add_notify_event_(base) == 0) { in evthread_make_base_notifiable_nolock_()
3544 base->th_notify_fn = event_kq_notify_base_; in evthread_make_base_notifiable_nolock_()
3552 base->th_notify_fd[0] = evutil_eventfd_(0, in evthread_make_base_notifiable_nolock_()
3554 if (base->th_notify_fd[0] >= 0) { in evthread_make_base_notifiable_nolock_()
3555 base->th_notify_fd[1] = -1; in evthread_make_base_notifiable_nolock_()
3560 if (evutil_make_internal_pipe_(base->th_notify_fd) == 0) { in evthread_make_base_notifiable_nolock_()
3567 base->th_notify_fn = notify; in evthread_make_base_notifiable_nolock_()
3570 event_assign(&base->th_notify, base, base->th_notify_fd[0], in evthread_make_base_notifiable_nolock_()
3571 EV_READ|EV_PERSIST, cb, base); in evthread_make_base_notifiable_nolock_()
3574 base->th_notify.ev_flags |= EVLIST_INTERNAL; in evthread_make_base_notifiable_nolock_()
3575 event_priority_set(&base->th_notify, 0); in evthread_make_base_notifiable_nolock_()
3577 return event_add_nolock_(&base->th_notify, NULL, 0); in evthread_make_base_notifiable_nolock_()
3581 event_base_foreach_event_nolock_(struct event_base *base, in event_base_foreach_event_nolock_() argument
3589 if ((r = evmap_foreach_event_(base, fn, arg))) in event_base_foreach_event_nolock_()
3594 for (u = 0; u < base->timeheap.n; ++u) { in event_base_foreach_event_nolock_()
3595 ev = base->timeheap.p[u]; in event_base_foreach_event_nolock_()
3600 if ((r = fn(base, ev, arg))) in event_base_foreach_event_nolock_()
3606 for (i = 0; i < base->n_common_timeouts; ++i) { in event_base_foreach_event_nolock_()
3608 base->common_timeout_queues[i]; in event_base_foreach_event_nolock_()
3615 if ((r = fn(base, ev, arg))) in event_base_foreach_event_nolock_()
3622 for (i = 0; i < base->nactivequeues; ++i) { in event_base_foreach_event_nolock_()
3624 TAILQ_FOREACH(evcb, &base->activequeues[i], evcb_active_next) { in event_base_foreach_event_nolock_()
3632 if ((r = fn(base, ev, arg))) in event_base_foreach_event_nolock_()
3643 dump_inserted_event_fn(const struct event_base *base, const struct event *e, void *arg) in dump_inserted_event_fn() argument
3664 evutil_timeradd(&tv, &base->tv_clock_diff, &tv); in dump_inserted_event_fn()
3676 dump_active_event_fn(const struct event_base *base, const struct event *e, void *arg) in dump_active_event_fn() argument
3699 event_base_foreach_event(struct event_base *base, in event_base_foreach_event() argument
3703 if ((!fn) || (!base)) { in event_base_foreach_event()
3706 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_foreach_event()
3707 r = event_base_foreach_event_nolock_(base, fn, arg); in event_base_foreach_event()
3708 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_foreach_event()
3714 event_base_dump_events(struct event_base *base, FILE *output) in event_base_dump_events() argument
3716 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_dump_events()
3718 event_base_foreach_event_nolock_(base, dump_inserted_event_fn, output); in event_base_dump_events()
3721 event_base_foreach_event_nolock_(base, dump_active_event_fn, output); in event_base_dump_events()
3722 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_dump_events()
3726 event_base_active_by_fd(struct event_base *base, evutil_socket_t fd, short events) in event_base_active_by_fd() argument
3728 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_active_by_fd()
3729 evmap_io_active_(base, fd, events & (EV_READ|EV_WRITE|EV_CLOSED)); in event_base_active_by_fd()
3730 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_active_by_fd()
3734 event_base_active_by_signal(struct event_base *base, int sig) in event_base_active_by_signal() argument
3736 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_active_by_signal()
3737 evmap_signal_active_(base, sig, 1); in event_base_active_by_signal()
3738 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_active_by_signal()
3743 event_base_add_virtual_(struct event_base *base) in event_base_add_virtual_() argument
3745 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_add_virtual_()
3746 base->virtual_event_count++; in event_base_add_virtual_()
3747 MAX_EVENT_COUNT(base->virtual_event_count_max, base->virtual_event_count); in event_base_add_virtual_()
3748 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_add_virtual_()
3752 event_base_del_virtual_(struct event_base *base) in event_base_del_virtual_() argument
3754 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_del_virtual_()
3755 EVUTIL_ASSERT(base->virtual_event_count > 0); in event_base_del_virtual_()
3756 base->virtual_event_count--; in event_base_del_virtual_()
3757 if (base->virtual_event_count == 0 && EVBASE_NEED_NOTIFY(base)) in event_base_del_virtual_()
3758 evthread_notify_base(base); in event_base_del_virtual_()
3759 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_del_virtual_()
3828 event_base_assert_ok_(struct event_base *base) in event_base_assert_ok_() argument
3830 EVBASE_ACQUIRE_LOCK(base, th_base_lock); in event_base_assert_ok_()
3831 event_base_assert_ok_nolock_(base); in event_base_assert_ok_()
3832 EVBASE_RELEASE_LOCK(base, th_base_lock); in event_base_assert_ok_()
3836 event_base_assert_ok_nolock_(struct event_base *base) in event_base_assert_ok_nolock_() argument
3842 evmap_check_integrity_(base); in event_base_assert_ok_nolock_()
3845 for (i = 1; i < (int)base->timeheap.n; ++i) { in event_base_assert_ok_nolock_()
3848 ev = base->timeheap.p[i]; in event_base_assert_ok_nolock_()
3849 p_ev = base->timeheap.p[parent]; in event_base_assert_ok_nolock_()
3856 for (i = 0; i < base->n_common_timeouts; ++i) { in event_base_assert_ok_nolock_()
3857 struct common_timeout_list *ctl = base->common_timeout_queues[i]; in event_base_assert_ok_nolock_()
3866 EVUTIL_ASSERT(is_common_timeout(&ev->ev_timeout,base)); in event_base_assert_ok_nolock_()
3874 for (i = 0; i < base->nactivequeues; ++i) { in event_base_assert_ok_nolock_()
3876 EVUTIL_ASSERT_TAILQ_OK(&base->activequeues[i], event_callback, evcb_active_next); in event_base_assert_ok_nolock_()
3877 TAILQ_FOREACH(evcb, &base->activequeues[i], evcb_active_next) { in event_base_assert_ok_nolock_()
3886 TAILQ_FOREACH(evcb, &base->active_later_queue, evcb_active_next) { in event_base_assert_ok_nolock_()
3891 EVUTIL_ASSERT(count == base->event_count_active); in event_base_assert_ok_nolock_()