mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-15 01:55:03 +00:00
Added more job_fifo concurrency protections.
This commit is contained in:
parent
3ba3815b64
commit
d4979d9403
1 changed files with 6 additions and 2 deletions
4
httpd.c
4
httpd.c
|
@ -257,6 +257,7 @@ void job_post(const xs_val *job)
|
||||||
pthread_mutex_lock(&job_mutex);
|
pthread_mutex_lock(&job_mutex);
|
||||||
|
|
||||||
/* add to the fifo */
|
/* add to the fifo */
|
||||||
|
if (job_fifo != NULL)
|
||||||
job_fifo = xs_list_append(job_fifo, job);
|
job_fifo = xs_list_append(job_fifo, job);
|
||||||
|
|
||||||
/* unlock the mutex */
|
/* unlock the mutex */
|
||||||
|
@ -278,6 +279,7 @@ void job_wait(xs_val **job)
|
||||||
pthread_mutex_lock(&job_mutex);
|
pthread_mutex_lock(&job_mutex);
|
||||||
|
|
||||||
/* dequeue */
|
/* dequeue */
|
||||||
|
if (job_fifo != NULL)
|
||||||
job_fifo = xs_list_shift(job_fifo, job);
|
job_fifo = xs_list_shift(job_fifo, job);
|
||||||
|
|
||||||
/* unlock the mutex */
|
/* unlock the mutex */
|
||||||
|
@ -465,7 +467,9 @@ void httpd(void)
|
||||||
for (n = 0; n < n_threads; n++)
|
for (n = 0; n < n_threads; n++)
|
||||||
pthread_join(threads[n], NULL);
|
pthread_join(threads[n], NULL);
|
||||||
|
|
||||||
|
pthread_mutex_lock(&job_mutex);
|
||||||
job_fifo = xs_free(job_fifo);
|
job_fifo = xs_free(job_fifo);
|
||||||
|
pthread_mutex_unlock(&job_mutex);
|
||||||
|
|
||||||
srv_log(xs_fmt("httpd stop %s:%d", address, port));
|
srv_log(xs_fmt("httpd stop %s:%d", address, port));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue