diff options
| author | 2022-10-13 15:56:19 +0200 | |
|---|---|---|
| committer | 2022-10-13 15:56:19 +0200 | |
| commit | 8635c5df9049dbeba39f4b22a3397c623d5f8304 (patch) | |
| tree | 1904270f07f3ec7edbb6dc21e21fb2f43708274e /httpd.c | |
| parent | New command-line command 'unfollow'. (diff) | |
| download | snac2-8635c5df9049dbeba39f4b22a3397c623d5f8304.tar.gz snac2-8635c5df9049dbeba39f4b22a3397c623d5f8304.tar.xz snac2-8635c5df9049dbeba39f4b22a3397c623d5f8304.zip | |
The waiting of the queue thread is done in a more appropriate way.
Diffstat (limited to 'httpd.c')
| -rw-r--r-- | httpd.c | 12 |
1 files changed, 11 insertions, 1 deletions
| @@ -200,6 +200,9 @@ void term_handler(int s) | |||
| 200 | static void *queue_thread(void *arg) | 200 | static 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")); |