static void memstore_pub_debug_start() { #ifdef PUB_FAKE_WORKER memstore_fakeprocess_push(PUB_FAKE_WORKER); #else memstore_fakeprocess_push_random(); #endif }
static void memstore_sub_debug_start() { #if FAKESHARD #ifdef SUB_FAKE_WORKER memstore_fakeprocess_push(SUB_FAKE_WORKER); #else memstore_fakeprocess_push_random(); #endif #endif }
static void sudden_abort_handler(subscriber_t *sub) { #if FAKESHARD full_subscriber_t *fsub = (full_subscriber_t *)sub; memstore_fakeprocess_push(fsub->data.owner); #endif sub->fn->dequeue(sub); #if FAKESHARD memstore_fakeprocess_pop(); #endif }
void nchan_subscriber_timeout_ev_handler(ngx_event_t *ev) { subscriber_t *sub = (subscriber_t *)ev->data; #if FAKESHARD memstore_fakeprocess_push(sub->owner); #endif sub->dequeue_after_response = 1; sub->fn->respond_status(sub, NGX_HTTP_REQUEST_TIMEOUT, &NCHAN_HTTP_STATUS_408); #if FAKESHARD memstore_fakeprocess_pop(); #endif }
static void timeout_ev_handler(ngx_event_t *ev) { full_subscriber_t *fsub = (full_subscriber_t *)ev->data; #if FAKESHARD memstore_fakeprocess_push(fsub->data.owner); #endif fsub->data.timeout_handler(&fsub->sub, fsub->data.timeout_handler_data); fsub->sub.dequeue_after_response = 1; fsub->sub.fn->respond_status(&fsub->sub, NGX_HTTP_NOT_MODIFIED, NULL); #if FAKESHARD memstore_fakeprocess_pop(); #endif }
static void sudden_abort_handler(subscriber_t *sub) { full_subscriber_t *fsub = (full_subscriber_t *)sub; #if FAKESHARD memstore_fakeprocess_push(fsub->sub.owner); #endif fsub->connected = 0; sub->status = DEAD; sub->fn->dequeue(sub); #if FAKESHARD memstore_fakeprocess_pop(); #endif }
static void timeout_ev_handler(ngx_event_t *ev) { sub_data_t *d = (sub_data_t *)ev->data; #if FAKESHARD memstore_fakeprocess_push(d->owner); #endif DBG("%p timeout event. Ping originator to see if still needed.", d->sub); d->sub->reserve(d->sub); memstore_ipc_send_memstore_subscriber_keepalive(d->originator, d->chid, d->sub, d->foreign_chanhead, keepalive_reply_handler, d); #if FAKESHARD memstore_fakeprocess_pop(); #endif }
static void timeout_ev_handler(ngx_event_t *ev) { internal_subscriber_t *fsub = (internal_subscriber_t *)ev->data; #if FAKESHARD memstore_fakeprocess_push(fsub->owner); #endif DBG("%p (%s) timeout", fsub, fsub->sub.name); fsub->timeout_handler(&fsub->sub, fsub->timeout_handler_data); fsub->sub.dequeue_after_response = 1; fsub->sub.respond_status(&fsub->sub, NGX_HTTP_NOT_MODIFIED, NULL); #if FAKESHARD memstore_fakeprocess_pop(); #endif }
ngx_int_t ipc_alert(ipc_t *ipc, ngx_int_t slot, ngx_uint_t code, void *data, size_t data_size) { DBG("IPC send alert code %i to slot %i", code, slot); if(data_size > IPC_DATA_SIZE) { ERR("IPC_DATA_SIZE too small. wanted %i, have %i", data_size, IPC_DATA_SIZE); assert(0); } nchan_update_stub_status(ipc_total_alerts_sent, 1); #if (FAKESHARD) ipc_alert_t alert = {0}; alert.src_slot = memstore_slot(); alert.time_sent = ngx_time(); alert.worker_generation = memstore_worker_generation; alert.code = code; ngx_memcpy(alert.data, data, data_size); //switch to destination memstore_fakeprocess_push(slot); ipc->handler(alert.src_slot, alert.code, alert.data); memstore_fakeprocess_pop(); //switch back #else ipc_process_t *proc = &ipc->process[slot]; ipc_writebuf_t *wb = &proc->wbuf; ipc_alert_t *alert; assert(proc->active); nchan_update_stub_status(ipc_queue_size, 1); if(wb->n < IPC_WRITEBUF_SIZE) { alert = &wb->alerts[(wb->first + wb->n++) % IPC_WRITEBUF_SIZE]; } else { //overflow ipc_writebuf_overflow_t *overflow; DBG("writebuf overflow, allocating memory"); if((overflow = ngx_alloc(sizeof(*overflow), ngx_cycle->log)) == NULL) { ERR("can't allocate memory for IPC write buffer overflow"); return NGX_ERROR; } overflow->next = NULL; alert= &overflow->alert; if(wb->overflow_first == NULL) { wb->overflow_first = overflow; } if(wb->overflow_last) { wb->overflow_last->next = overflow; } wb->overflow_last = overflow; wb->overflow_n++; } alert->src_slot = ngx_process_slot; alert->time_sent = ngx_time(); alert->code = code; alert->worker_generation = memstore_worker_generation; ngx_memcpy(&alert->data, data, data_size); ipc_write_handler(proc->c->write); //ngx_handle_write_event(ipc->c[slot]->write, 0); //ngx_add_event(ipc->c[slot]->write, NGX_WRITE_EVENT, NGX_CLEAR_EVENT); #endif return NGX_OK; }