static void *run_event_loop(oop_source_sys *source_sys) { void *oop_result = oop_sys_run(source_sys); if (oop_result == OOP_ERROR) fprintf(stderr, "%s: oop system source returned error\n", prog_name); else if (oop_result == OOP_CONTINUE) { /* * Normal termination */ #ifdef RULI_HOST_DEBUG fprintf(stderr, "%s: oop system source had no event registered\n", prog_name); #endif } else if (oop_result == OOP_HALT) fprintf(stderr, "%s: some sink requested oop system halt\n", prog_name); else fprintf(stderr, "%s: unexpected oop system source result (!)\n", prog_name); return oop_result; }
/* return on failure or (with 0) if all fd events are removed */ static int oop_event_loop_wait(struct event_context *ev) { void *oop_ret; oop_source_sys *oop_sys = ev->additional_data; oop_ret = oop_sys_run(oop_sys); if (oop_ret == OOP_CONTINUE) { return 0; } return -1; }
static void go(int retry, int timeout, ruli_list_t *server_list) { oop_source_sys *source_sys; /* System event source */ oop_source *source; /* Event registration interface */ ruli_res_t res_ctx; int result; ruli_conf_handler_t handler; /* * Create event source */ create_oop_source(&source_sys, &source); /* * Initialize resolver */ handler.opaque = server_list; handler.search_loader = load_search_list; handler.search_unloader = unload_search_list; handler.ns_loader = load_ns_list; handler.ns_unloader = unload_ns_list; res_ctx.res_conf_handler = &handler; res_ctx.res_source = source; res_ctx.res_retry = retry; res_ctx.res_timeout = timeout; result = ruli_res_new(&res_ctx); if (result) { fprintf(stderr, "%s: can't create ruli resolver: %s [%d]\n", prog_name, ruli_res_errstr(result), result); exit(1); } /* * Monitor stdin for read */ { int std_in = 0; set_non_blocking(std_in); source->on_fd(source, std_in, OOP_READ, on_stdin_read, &res_ctx); } /* * Run event loop */ { void *oop_result = oop_sys_run(source_sys); if (oop_result == OOP_ERROR) fprintf(stderr, "%s: oop system source returned error\n", prog_name); else if (oop_result == OOP_CONTINUE) { /* * Normal termination */ #ifdef SRVSOLVER_DEBUG fprintf(stderr, "%s: oop system source had no event registered\n", prog_name); #endif } else if (oop_result == OOP_HALT) fprintf(stderr, "%s: some sink requested oop system halt\n", prog_name); else fprintf(stderr, "%s: unexpected oop system source result (!)\n", prog_name); } /* * Destroy resolver */ ruli_res_delete(&res_ctx); /* * Destroy event source */ oop_sys_delete(source_sys); }