int tube_setup_bg_listen(struct tube* tube, struct comm_base* base, tube_callback_t* cb, void* arg) { tube->listen_cb = cb; tube->listen_arg = arg; if(!comm_base_internal(base)) return 1; /* ignore when no comm base - testing */ return winsock_register_wsaevent(comm_base_internal(base), &tube->ev_listen, tube->event, &tube_handle_signal, tube); }
void wsvc_setup_worker(struct worker* worker) { /* if not started with -w service, do nothing */ if(!service_stop_event) return; if(!winsock_register_wsaevent(comm_base_internal(worker->base), &service_stop_ev, service_stop_event, &worker_win_stop_cb, worker)) { fatal_exit("could not register wsaevent"); return; } if(!service_cron) { service_cron = comm_timer_create(worker->base, wsvc_cron_cb, worker); if(!service_cron) fatal_exit("could not create cron timer"); set_cron_timer(); } }
struct ub_event* ub_winsock_register_wsaevent(struct ub_event_base* base, void* wsaevent, void (*cb)(int, short, void*), void* arg) { #if defined(USE_MINI_EVENT) && defined(USE_WINSOCK) struct event *ev = (struct event*)calloc(1, sizeof(struct event)); if (!ev) return NULL; if (winsock_register_wsaevent(AS_EVENT_BASE(base), ev, wsaevent, cb, arg)) return AS_UB_EVENT(ev); free(ev); return NULL; #else (void)base; (void)wsaevent; (void)cb; (void)arg; return NULL; #endif }