static void output_handler_done (PacketPassFifoQueue *o) { DebugObject_Access(&o->d_obj); ASSERT(o->sending_flow) ASSERT(!BPending_IsSet(&o->schedule_job)) ASSERT(!o->freeing) ASSERT(!o->sending_flow->is_waiting) PacketPassFifoQueueFlow *flow = o->sending_flow; // set no sending flow o->sending_flow = NULL; // schedule schedule job BPending_Set(&o->schedule_job); // done input PacketPassInterface_Done(&flow->input); // call busy handler if set if (flow->handler_busy) { // handler is one-shot, unset it before calling PacketPassFifoQueue_handler_busy handler = flow->handler_busy; flow->handler_busy = NULL; // call handler handler(flow->user); return; } }
static void listener_olap_handler (BListener *o, int event, DWORD bytes) { DebugObject_Access(&o->d_obj); ASSERT(o->busy) ASSERT(!o->ready) ASSERT(event == BREACTOR_IOCP_EVENT_SUCCEEDED || event == BREACTOR_IOCP_EVENT_FAILED) // set not busy o->busy = 0; // schedule next accept BPending_Set(&o->next_job); if (event == BREACTOR_IOCP_EVENT_FAILED) { BLog(BLOG_ERROR, "accepting failed"); // close new socket if (closesocket(o->newsock) == SOCKET_ERROR) { BLog(BLOG_ERROR, "closesocket failed"); } return; } BLog(BLOG_INFO, "connection accepted"); // set ready o->ready = 1; // call handler o->handler(o->user); return; }
static void work_signals (BProcessManager *o) { // read exit status with waitpid() int status; pid_t pid = waitpid(-1, &status, WNOHANG); if (pid <= 0) { return; } // schedule next waitpid BPending_Set(&o->wait_job); // find process BProcess *p = find_process(o, pid); if (!p) { BLog(BLOG_DEBUG, "unknown child %p"); } if (WIFEXITED(status)) { uint8_t exit_status = WEXITSTATUS(status); BLog(BLOG_INFO, "child %"PRIiMAX" exited with status %"PRIu8, (intmax_t)pid, exit_status); if (p) { call_handler(p, 1, exit_status); return; } } else if (WIFSIGNALED(status)) { int signo = WTERMSIG(status); BLog(BLOG_INFO, "child %"PRIiMAX" exited with signal %d", (intmax_t)pid, signo); if (p) { call_handler(p, 0, 0); return; } } else { BLog(BLOG_ERROR, "unknown wait status type for pid %"PRIiMAX" (%d)", (intmax_t)pid, status); } }