summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2022-10-13 15:56:19 +0200
committerdefault <nobody@localhost>2022-10-13 15:56:19 +0200
commit8635c5df9049dbeba39f4b22a3397c623d5f8304 (patch)
tree1904270f07f3ec7edbb6dc21e21fb2f43708274e
parent45f0988fb390f20356e6cc03d7303367122fc465 (diff)
The waiting of the queue thread is done in a more appropriate way.
-rw-r--r--httpd.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/httpd.c b/httpd.c
index 8c340b8..9bfee12 100644
--- a/httpd.c
+++ b/httpd.c
@@ -200,6 +200,9 @@ void term_handler(int s)
static void *queue_thread(void *arg)
/* queue thread (queue management) */
{
+ pthread_mutex_t dummy_mutex = PTHREAD_MUTEX_INITIALIZER;
+ pthread_cond_t dummy_cond = PTHREAD_COND_INITIALIZER;
+
srv_log(xs_fmt("queue thread start"));
while (srv_running) {
@@ -216,7 +219,14 @@ static void *queue_thread(void *arg)
}
}
- sleep(3);
+ /* sleep 3 seconds */
+ struct timespec ts;
+ clock_gettime(CLOCK_REALTIME, &ts);
+ ts.tv_sec += 3;
+
+ pthread_mutex_lock(&dummy_mutex);
+ while (pthread_cond_timedwait(&dummy_cond, &dummy_mutex, &ts) == 0);
+ pthread_mutex_unlock(&dummy_mutex);
}
srv_log(xs_fmt("queue thread stop"));