int main() { struct skaidrus_instance si; fprintf(stderr, "skaidrus, an example transparent proxy application\n"); fprintf(stderr, "\n"); if (geteuid() != 0) { fprintf(stderr, "error: need root privileges for performing " "transparent proxy functions\n"); return 1; } if (detect_tproxy_v2()) { fprintf(stderr, "error: version >= 2.0.0 of linux transparent " "proxy patches not detected\n"); return 1; } iv_init(); openlog("skaidrus", LOG_NDELAY | LOG_PERROR, LOG_USER); si.local_addr.sin_family = AF_INET; si.local_addr.sin_addr.s_addr = htonl(INADDR_ANY); si.local_addr.sin_port = htons(9841); if (!register_skaidrus_instance(&si)) { fprintf(stderr, "can't register skaidrus instance\n"); return 1; } fprintf(stderr, "up and running\n"); iv_main(); return 0; }
static void iv_work_thread(void *_thr) { struct work_pool_thread *thr = _thr; struct work_pool_priv *pool = thr->pool; iv_init(); INIT_IV_LIST_HEAD(&thr->list); thr->kicked = 0; IV_EVENT_INIT(&thr->kick); thr->kick.cookie = thr; thr->kick.handler = iv_work_thread_got_event; iv_event_register(&thr->kick); IV_TIMER_INIT(&thr->idle_timer); thr->idle_timer.cookie = thr; thr->idle_timer.handler = iv_work_thread_idle_timeout; if (pool->thread_start != NULL) pool->thread_start(pool->cookie); iv_event_post(&thr->kick); iv_main(); iv_deinit(); }
static void log_threaded_dest_driver_worker_thread_main(gpointer arg) { LogThrDestDriver *self = (LogThrDestDriver *)arg; iv_init(); msg_debug("Worker thread started", evt_tag_str("driver", self->super.super.id), NULL); log_queue_set_use_backlog(self->queue, TRUE); log_threaded_dest_driver_init_watches(self); log_threaded_dest_driver_start_watches(self); if (self->worker.thread_init) self->worker.thread_init(self); iv_main(); __disconnect(self); if (self->worker.thread_deinit) self->worker.thread_deinit(self); msg_debug("Worker thread finished", evt_tag_str("driver", self->super.super.id), NULL); iv_deinit(); }
void test_source_run_tests(TestSource *self) { self->current_test = self->tests; while (self->current_test) { self->current_test_case = self->current_test->data; iv_task_register(&self->start); iv_main(); log_pipe_deinit(&self->super); self->current_test = self->current_test->next; } }
int main() { struct req req[NUM]; int i; iv_init(); for (i = 0; i < NUM; i++) open_child_request(&req[i]); iv_main(); iv_deinit(); return 0; }
int main() { iv_init(); IV_EVENT_RAW_INIT(&ev0); ev0.handler = gotev0; iv_event_raw_register(&ev0); iv_event_raw_post(&ev0); iv_main(); iv_deinit(); return 0; }
void main_loop_run(void) { msg_notice("syslog-ng starting up", evt_tag_str("version", SYSLOG_NG_VERSION)); /* main loop */ service_management_indicate_readiness(); service_management_clear_status(); if (interactive_mode) { plugin_load_module("python", current_configuration, NULL); debugger_start(current_configuration); } iv_main(); service_management_publish_status("Shutting down..."); }
static void thr_child(void *_dummy) { iv_init(); IV_EVENT_INIT(&ev_child); ev_child.handler = got_ev_child; iv_event_register(&ev_child); iv_validate_now(); tim_start = iv_now; iv_event_post(&ev_parent); iv_main(); iv_deinit(); }
int main() { iv_init(); iv_thread_set_debug_state(1); iv_thread_create("return", thr_return, NULL); iv_thread_create("selfcancel", thr_selfcancel, NULL); iv_thread_create("exit", thr_exit, NULL); iv_thread_list_children(); iv_main(); iv_deinit(); return 0; }
int main() { iv_init(); iv_thread_set_debug_state(1); IV_WORK_POOL_INIT(&pool); pool.max_threads = 8; iv_work_pool_create(&pool); IV_WORK_ITEM_INIT(&item_a); item_a.cookie = "a"; item_a.work = work; item_a.completion = work_complete; iv_work_pool_submit_work(&pool, &item_a); IV_WORK_ITEM_INIT(&item_b); item_b.cookie = "b"; item_b.work = work; item_b.completion = work_complete; iv_work_pool_submit_work(&pool, &item_b); IV_WORK_ITEM_INIT(&item_c); item_c.cookie = "c"; item_c.work = work; item_c.completion = work_complete; iv_work_pool_submit_work(&pool, &item_c); IV_WORK_ITEM_INIT(&item_d); item_d.cookie = "d"; item_d.work = work; item_d.completion = work_complete; iv_work_pool_submit_work(&pool, &item_d); item_count = 4; iv_main(); iv_deinit(); return 0; }
int main() { long long nsec; iv_init(); #ifdef USE_SIGNAL signal(SIGALRM, got_signal_timeout); alarm(5); #else IV_TIMER_INIT(&timeout); iv_validate_now(); timeout.expires = iv_now; timeout.expires.tv_sec += 5; timeout.handler = got_timer_timeout; iv_timer_register(&timeout); #endif IV_SIGNAL_INIT(&is); is.signum = SIGUSR1; is.handler = got_sig; iv_signal_register(&is); iv_validate_now(); tim_start = iv_now; raise(SIGUSR1); iv_main(); iv_deinit(); nsec = 1000000000ULL * (tim_end.tv_sec - tim_start.tv_sec) + (tim_end.tv_nsec - tim_start.tv_nsec); printf("%s: %d in %ld nsec => %d/sec\n", iv_poll_method_name(), sig_received, (long)nsec, (int)(1000000000ULL * sig_received / nsec)); return 0; }
int main() { long long nsec; iv_init(); #ifdef USE_SIGNAL signal(SIGALRM, got_signal_timeout); alarm(5); #else IV_TIMER_INIT(&timeout); iv_validate_now(); timeout.expires = iv_now; timeout.expires.tv_sec += 5; timeout.handler = got_timer_timeout; iv_timer_register(&timeout); #endif IV_EVENT_RAW_INIT(&ev); ev.handler = got_ev; iv_event_raw_register(&ev); iv_validate_now(); tim_start = iv_now; iv_event_raw_post(&ev); iv_main(); iv_deinit(); nsec = 1000000000ULL * (tim_end.tv_sec - tim_start.tv_sec) + (tim_end.tv_nsec - tim_start.tv_nsec); printf("%s: %d in %ld nsec => %d/sec\n", iv_poll_method_name(), ev_received, (long)nsec, (int)(1000000000ULL * ev_received / nsec)); return 0; }
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; }
int main(int argc, char **argv) { struct iv_inotify inotify; int i; if (argc < 2) { fprintf(stderr, "Usage: %s FILE...\n", argv[0]); return 1; } iv_init(); IV_INOTIFY_INIT(&inotify); iv_inotify_register(&inotify); for (i = 1; i < argc; i++) { struct iv_inotify_watch *w; w = malloc(sizeof(*w)); if (w == NULL) { perror("malloc"); return 1; } IV_INOTIFY_WATCH_INIT(w); w->inotify = &inotify; w->pathname = argv[i]; w->mask = IN_ALL_EVENTS; w->cookie = w; w->handler = test_handler; iv_inotify_watch_register(w); } iv_main(); iv_deinit(); return 0; }
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")); }
void shell_iv( int argc, char **argv ) { iv_main( argc, argv ); clearerr( stdin ); }