static void * np_wthread_proc(void *a) { Npwthread *wt = (Npwthread *)a; Nptpool *tp = wt->tpool; Npreq *req = NULL; Npfcall *rc; xpthread_mutex_lock(&tp->lock); while (!wt->shutdown) { wt->state = WT_IDLE; req = tp->reqs_first; if (!req) { xpthread_cond_wait(&tp->reqcond, &tp->lock); continue; } np_srv_remove_req(tp, req); np_srv_add_workreq(tp, req); xpthread_mutex_unlock(&tp->lock); req->wthread = wt; wt->state = WT_WORK; rc = np_process_request(req, &tp->stats); if (rc) { wt->state = WT_REPLY; np_respond(tp, req, rc); } xpthread_mutex_lock(&tp->lock); } xpthread_mutex_unlock (&tp->lock); wt->state = WT_SHUT; return NULL; }
static void * np_wthread_proc(void *a) { Npwthread *wt; Npsrv *srv; Npreq *req; Npfcall *rc; wt = a; srv = wt->srv; req = NULL; pthread_setspecific(wthread_key, a); pthread_mutex_lock(&srv->lock); while (!wt->shutdown) { req = srv->reqs_first; if (!req) { pthread_cond_wait(&srv->reqcond, &srv->lock); continue; } np_srv_remove_request(srv, req); if (srv->workreqs) srv->workreqs->prev = req; req->next = srv->workreqs; srv->workreqs = req; req->prev = NULL; req->wthread = a; pthread_mutex_unlock(&srv->lock); rc = np_process_request(req); if (rc) np_respond(req, rc); pthread_mutex_lock(&srv->lock); } return NULL; }