void main_loop_deinit(void) { main_loop_free_config(); if (!syntax_only) control_destroy(); iv_event_unregister(&exit_requested); iv_event_unregister(&reload_config_requested); main_loop_call_deinit(); main_loop_io_worker_deinit(); main_loop_worker_deinit(); }
/* main thread **************************************************************/ static void iv_work_event(void *_pool) { struct work_pool_priv *pool = _pool; struct iv_list_head items; mutex_lock(&pool->lock); __iv_list_steal_elements(&pool->work_done, &items); mutex_unlock(&pool->lock); while (!iv_list_empty(&items)) { struct iv_work_item *work; work = iv_container_of(items.next, struct iv_work_item, list); iv_list_del(&work->list); work->completion(work->cookie); } if (pool->shutting_down) { mutex_lock(&pool->lock); if (!pool->started_threads && iv_list_empty(&pool->work_done)) { mutex_unlock(&pool->lock); mutex_destroy(&pool->lock); iv_event_unregister(&pool->ev); free(pool); return; } mutex_unlock(&pool->lock); } }
static gboolean log_reader_deinit(LogPipe *s) { LogReader *self = (LogReader *) s; main_loop_assert_main_thread(); iv_event_unregister(&self->schedule_wakeup); iv_event_unregister(&self->last_msg_sent_event); log_reader_stop_watches(self); log_reader_stop_idle_timer(self); if (!log_source_deinit(s)) return FALSE; return TRUE; }
static gboolean afinter_source_deinit(LogPipe *s) { AFInterSource *self = (AFInterSource *) s; g_static_mutex_lock(&internal_msg_lock); current_internal_source = NULL; g_static_mutex_unlock(&internal_msg_lock); /* the post handler can now be unregistered as current_internal_source is * set to NULL. Locks are only used as a memory barrier. */ iv_event_unregister(&self->post); iv_event_unregister(&self->schedule_wakeup); afinter_source_stop_watches(self); return log_source_deinit(s); }
static void got_ev_child(void *_dummy) { if (die == 2) { die = 3; iv_event_post(&ev_parent); iv_event_unregister(&ev_child); } else { iv_event_post(&ev_parent); } }
static void got_ev_parent(void *_dummy) { ev_received++; if (die == 0) { iv_event_post(&ev_child); } else if (die == 1) { die = 2; iv_event_post(&ev_child); } else if (die == 2) { iv_fatal("iv_event_bench: entered invalid state"); } else if (die == 3) { iv_validate_now(); tim_end = iv_now; iv_event_unregister(&ev_parent); } }
/* worker thread ************************************************************/ static void __iv_work_thread_die(struct work_pool_thread *thr) { struct work_pool_priv *pool = thr->pool; if (thr->kicked) iv_fatal("__iv_work_thread_die: called on kicked thread"); iv_event_unregister(&thr->kick); free(thr); pool->started_threads--; if (pool->thread_stop != NULL) pool->thread_stop(pool->cookie); if (pool->shutting_down && !pool->started_threads) iv_event_post(&pool->ev); }