From dc3dd18e924720e8d7aac295f8353e6cfb447366 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 1 Aug 2014 13:28:55 +1000 Subject: [PATCH] Add a slow 1s timedwait to ckmsg_queue parsing to not miss wakeups --- src/ckpool.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ckpool.c b/src/ckpool.c index 4490ab84..5b212564 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -112,16 +112,21 @@ static void *ckmsg_queue(void *arg) while (42) { ckmsg_t *msg; + tv_t now; + ts_t abs; mutex_lock(&ckmsgq->lock); + tv_time(&now); + tv_to_ts(&abs, &now); + abs.tv_sec++; if (!ckmsgq->msgs) - pthread_cond_wait(&ckmsgq->cond, &ckmsgq->lock); + pthread_cond_timedwait(&ckmsgq->cond, &ckmsgq->lock, &abs); msg = ckmsgq->msgs; - if (likely(msg)) + if (msg) DL_DELETE(ckmsgq->msgs, msg); mutex_unlock(&ckmsgq->lock); - if (unlikely(!msg)) + if (!msg) continue; ckmsgq->func(ckp, msg->data); free(msg);