{
struct worker *w, ww;
struct wq *qp;
- char c;
unsigned char wlog[8192]; /* XXX: size */
THR_Name("cache-worker");
w->used = TIM_real();
w->wlb = w->wlp = wlog;
w->wle = wlog + sizeof wlog;
- AZ(pipe(w->pipe));
+ AZ(pthread_cond_init(&w->cond, NULL));
VSL(SLT_WorkThread, 0, "%p start", w);
LOCK(&tmtx);
if (w->wrq == NULL) {
LOCK(&qp->mtx);
VTAILQ_INSERT_HEAD(&qp->idle, w, list);
+ AZ(pthread_cond_wait(&w->cond, &qp->mtx));
UNLOCK(&qp->mtx);
- assert(1 == read(w->pipe[0], &c, 1));
}
if (w->wrq == NULL)
break;
VSL(SLT_WorkThread, 0, "%p end", w);
if (w->vcl != NULL)
VCL_Rel(&w->vcl);
- AZ(close(w->pipe[0]));
- AZ(close(w->pipe[1]));
+ AZ(pthread_cond_destroy(&w->cond));
if (w->srcaddr != NULL)
free(w->srcaddr);
if (w->nobjhead != NULL) {
VTAILQ_REMOVE(&qp->idle, w, list);
UNLOCK(&qp->mtx);
w->wrq = &sp->workreq;
- assert(1 == write(w->pipe[1], w, 1));
+ AZ(pthread_cond_signal(&w->cond));
return;
}
if (w == NULL)
continue;
AZ(w->wrq);
- assert(1 == write(w->pipe[1], w, 1));
+ AZ(pthread_cond_signal(&w->cond));
}
}
}