static void log_threaded_dest_driver_init_watches(LogThrDestDriver* self) { IV_EVENT_INIT(&self->wake_up_event); self->wake_up_event.cookie = self; self->wake_up_event.handler = log_threaded_dest_driver_wake_up; iv_event_register(&self->wake_up_event); IV_EVENT_INIT(&self->shutdown_event); self->shutdown_event.cookie = self; self->shutdown_event.handler = log_threaded_dest_driver_shutdown; iv_event_register(&self->shutdown_event); IV_TIMER_INIT(&self->timer_reopen); self->timer_reopen.cookie = self; self->timer_reopen.handler = log_threaded_dest_driver_do_work; IV_TIMER_INIT(&self->timer_throttle); self->timer_throttle.cookie = self; self->timer_throttle.handler = log_threaded_dest_driver_do_work; IV_TASK_INIT(&self->do_work); self->do_work.cookie = self; self->do_work.handler = log_threaded_dest_driver_do_work; }
static void log_reader_init_watches(LogReader *self) { gint fd; GIOCondition cond; log_proto_prepare(self->proto, &fd, &cond); IV_FD_INIT(&self->fd_watch); self->fd_watch.cookie = self; IV_TIMER_INIT(&self->follow_timer); self->follow_timer.cookie = self; self->follow_timer.handler = log_reader_io_follow_file; IV_TASK_INIT(&self->restart_task); self->restart_task.cookie = self; self->restart_task.handler = log_reader_io_process_input; IV_EVENT_INIT(&self->schedule_wakeup); self->schedule_wakeup.cookie = self; self->schedule_wakeup.handler = log_reader_wakeup_triggered; main_loop_io_worker_job_init(&self->io_job); self->io_job.user_data = self; self->io_job.work = (void (*)(void *)) log_reader_work_perform; self->io_job.completion = (void (*)(void *)) log_reader_work_finished; }
TestSource * test_source_new(GlobalConfig *cfg) { TestSource *self = g_new0(TestSource, 1); log_pipe_init_instance(&self->super, cfg); self->super.init = __init; self->super.deinit = __deinit; self->super.free_fn = __free; self->super.queue = __queue; self->journald_mock = journald_mock_new(); journal_reader_options_defaults(&self->options); IV_TASK_INIT(&self->start); self->start.cookie = self; self->start.handler = __start_source; IV_TASK_INIT(&self->stop); self->stop.cookie = self; self->stop.handler = __stop_source; return self; }
static void afinter_source_init_watches(AFInterSource *self) { IV_EVENT_INIT(&self->post); self->post.cookie = self; self->post.handler = afinter_source_post; IV_TIMER_INIT(&self->mark_timer); self->mark_timer.cookie = self; self->mark_timer.handler = afinter_source_mark; IV_EVENT_INIT(&self->schedule_wakeup); self->schedule_wakeup.cookie = self; self->schedule_wakeup.handler = (void (*)(void *)) afinter_source_update_watches; IV_TASK_INIT(&self->restart_task); self->restart_task.cookie = self; self->restart_task.handler = afinter_source_post; }
static void log_reader_init_watches(LogReader *self) { IV_TASK_INIT(&self->restart_task); self->restart_task.cookie = self; self->restart_task.handler = log_reader_io_process_input; IV_EVENT_INIT(&self->schedule_wakeup); self->schedule_wakeup.cookie = self; self->schedule_wakeup.handler = log_reader_wakeup_triggered; main_loop_io_worker_job_init(&self->io_job); self->io_job.user_data = self; self->io_job.work = (void (*)(void *)) log_reader_work_perform; self->io_job.completion = (void (*)(void *)) log_reader_work_finished; }
static void _init_watches(JournalReader *self) { IV_EVENT_INIT(&self->schedule_wakeup); self->schedule_wakeup.cookie = self; self->schedule_wakeup.handler = _wakeup_triggered; iv_event_register(&self->schedule_wakeup); IV_TASK_INIT(&self->restart_task); self->restart_task.cookie = self; self->restart_task.handler = _io_process_input; main_loop_io_worker_job_init(&self->io_job); self->io_job.user_data = self; self->io_job.work = (void (*)(void *)) _work_perform; self->io_job.completion = (void (*)(void *)) _work_finished; }
void http_client_request_start(struct http_client_request *req) { req->state = EINPROGRESS; req->hostname_lookup_callback_scheduled = 0; IV_TASK_INIT(&req->hostname_lookup); req->hostname_lookup.cookie = (void *)req; req->hostname_lookup.handler = hostname_lookup_done; req->redirect = NULL; req->redirect_last = NULL; req->redirect_hostname = req->hostname; req->redirect_port = req->port; req->redirect_url = req->url; req->recursion_limit = 10; IV_FD_INIT(&req->fd); req->fd.fd = -1; start_hostname_lookup(req); }
int main() { alarm(5); iv_init(); IV_TASK_INIT(&task); task.handler = handler_task; iv_task_register(&task); IV_TIMER_INIT(&timer); iv_validate_now(); timer.expires = iv_now; timer.expires.tv_sec--; timer.handler = handler_timer; iv_main(); iv_deinit(); return !success; }
/* * this shuld replace the g_get_current_time and the g_source_get_current_time calls in the main thread * (log_msg_init, afinter_postpone_mark) */ void cached_g_current_time(GTimeVal *result) { if (current_time_value.tv_sec == 0) { g_get_current_time(¤t_time_value); } *result = current_time_value; if (iv_inited()) { if (invalidate_time_task.handler == NULL) { IV_TASK_INIT(&invalidate_time_task); invalidate_time_task.handler = (void (*)(void *)) invalidate_cached_time; } if (!iv_task_registered(&invalidate_time_task)) iv_task_register(&invalidate_time_task); } else { invalidate_cached_time(); } }
void __test_fd_handling(Journald *journald) { gint fd = journald_get_fd(journald); journald_process(journald); task_called = FALSE; poll_triggered = FALSE; struct iv_task add_entry_task; struct iv_fd fd_to_poll; struct iv_timer stop_timer; IV_TASK_INIT(&add_entry_task); add_entry_task.cookie = journald; add_entry_task.handler = add_mock_entries; IV_FD_INIT(&fd_to_poll); fd_to_poll.fd = fd; fd_to_poll.cookie = journald; fd_to_poll.handler_in = handle_new_entry; iv_validate_now(); IV_TIMER_INIT(&stop_timer); stop_timer.cookie = NULL; stop_timer.expires = iv_now; stop_timer.expires.tv_sec++; stop_timer.handler = stop_timer_expired; iv_task_register(&add_entry_task); iv_fd_register(&fd_to_poll); iv_timer_register(&stop_timer); iv_main(); assert_true(poll_triggered, ASSERTION_ERROR("Poll event isn't triggered")); }