summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2022-10-13 15:56:19 +0200
committerGravatar default2022-10-13 15:56:19 +0200
commit8635c5df9049dbeba39f4b22a3397c623d5f8304 (patch)
tree1904270f07f3ec7edbb6dc21e21fb2f43708274e
parentNew command-line command 'unfollow'. (diff)
downloadpenes-snac2-8635c5df9049dbeba39f4b22a3397c623d5f8304.tar.gz
penes-snac2-8635c5df9049dbeba39f4b22a3397c623d5f8304.tar.xz
penes-snac2-8635c5df9049dbeba39f4b22a3397c623d5f8304.zip
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)
200static void *queue_thread(void *arg) 200static void *queue_thread(void *arg)
201/* queue thread (queue management) */ 201/* queue thread (queue management) */
202{ 202{
203 pthread_mutex_t dummy_mutex = PTHREAD_MUTEX_INITIALIZER;
204 pthread_cond_t dummy_cond = PTHREAD_COND_INITIALIZER;
205
203 srv_log(xs_fmt("queue thread start")); 206 srv_log(xs_fmt("queue thread start"));
204 207
205 while (srv_running) { 208 while (srv_running) {
@@ -216,7 +219,14 @@ static void *queue_thread(void *arg)
216 } 219 }
217 } 220 }
218 221
219 sleep(3); 222 /* sleep 3 seconds */
223 struct timespec ts;
224 clock_gettime(CLOCK_REALTIME, &ts);
225 ts.tv_sec += 3;
226
227 pthread_mutex_lock(&dummy_mutex);
228 while (pthread_cond_timedwait(&dummy_cond, &dummy_mutex, &ts) == 0);
229 pthread_mutex_unlock(&dummy_mutex);
220 } 230 }
221 231
222 srv_log(xs_fmt("queue thread stop")); 232 srv_log(xs_fmt("queue thread stop"));