|
|
@ -137,27 +137,27 @@ static void *ckmsg_queue(void *arg) |
|
|
|
/* Generic workqueue function and message receiving and parsing thread */ |
|
|
|
/* Generic workqueue function and message receiving and parsing thread */ |
|
|
|
static void *ckwq_queue(void *arg) |
|
|
|
static void *ckwq_queue(void *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ckwq_t *ckmsgq = (ckwq_t *)arg; |
|
|
|
ckwq_t *ckwq = (ckwq_t *)arg; |
|
|
|
ckpool_t *ckp = ckmsgq->ckp; |
|
|
|
ckpool_t *ckp = ckwq->ckp; |
|
|
|
|
|
|
|
|
|
|
|
pthread_detach(pthread_self()); |
|
|
|
pthread_detach(pthread_self()); |
|
|
|
rename_proc(ckmsgq->name); |
|
|
|
rename_proc(ckwq->name); |
|
|
|
|
|
|
|
|
|
|
|
while (42) { |
|
|
|
while (42) { |
|
|
|
ckwqmsg_t *wqmsg; |
|
|
|
ckwqmsg_t *wqmsg; |
|
|
|
tv_t now; |
|
|
|
tv_t now; |
|
|
|
ts_t abs; |
|
|
|
ts_t abs; |
|
|
|
|
|
|
|
|
|
|
|
mutex_lock(ckmsgq->lock); |
|
|
|
mutex_lock(ckwq->lock); |
|
|
|
tv_time(&now); |
|
|
|
tv_time(&now); |
|
|
|
tv_to_ts(&abs, &now); |
|
|
|
tv_to_ts(&abs, &now); |
|
|
|
abs.tv_sec++; |
|
|
|
abs.tv_sec++; |
|
|
|
if (!ckmsgq->wqmsgs) |
|
|
|
if (!ckwq->wqmsgs) |
|
|
|
cond_timedwait(ckmsgq->cond, ckmsgq->lock, &abs); |
|
|
|
cond_timedwait(ckwq->cond, ckwq->lock, &abs); |
|
|
|
wqmsg = ckmsgq->wqmsgs; |
|
|
|
wqmsg = ckwq->wqmsgs; |
|
|
|
if (wqmsg) |
|
|
|
if (wqmsg) |
|
|
|
DL_DELETE(ckmsgq->wqmsgs, wqmsg); |
|
|
|
DL_DELETE(ckwq->wqmsgs, wqmsg); |
|
|
|
mutex_unlock(ckmsgq->lock); |
|
|
|
mutex_unlock(ckwq->lock); |
|
|
|
|
|
|
|
|
|
|
|
if (!wqmsg) |
|
|
|
if (!wqmsg) |
|
|
|
continue; |
|
|
|
continue; |
|
|
@ -209,7 +209,7 @@ ckmsgq_t *create_ckmsgqs(ckpool_t *ckp, const char *name, const void *func, cons |
|
|
|
|
|
|
|
|
|
|
|
ckwq_t *create_ckwqs(ckpool_t *ckp, const char *name, const int count) |
|
|
|
ckwq_t *create_ckwqs(ckpool_t *ckp, const char *name, const int count) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ckwq_t *ckwq = ckzalloc(sizeof(ckmsgq_t) * count); |
|
|
|
ckwq_t *ckwq = ckzalloc(sizeof(ckwq_t) * count); |
|
|
|
mutex_t *lock; |
|
|
|
mutex_t *lock; |
|
|
|
pthread_cond_t *cond; |
|
|
|
pthread_cond_t *cond; |
|
|
|
int i; |
|
|
|
int i; |
|
|
|