mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-14 17:45:04 +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
8
httpd.c
8
httpd.c
|
@ -257,7 +257,8 @@ void job_post(const xs_val *job)
|
|||
pthread_mutex_lock(&job_mutex);
|
||||
|
||||
/* add to the fifo */
|
||||
job_fifo = xs_list_append(job_fifo, job);
|
||||
if (job_fifo != NULL)
|
||||
job_fifo = xs_list_append(job_fifo, job);
|
||||
|
||||
/* unlock the mutex */
|
||||
pthread_mutex_unlock(&job_mutex);
|
||||
|
@ -278,7 +279,8 @@ void job_wait(xs_val **job)
|
|||
pthread_mutex_lock(&job_mutex);
|
||||
|
||||
/* dequeue */
|
||||
job_fifo = xs_list_shift(job_fifo, job);
|
||||
if (job_fifo != NULL)
|
||||
job_fifo = xs_list_shift(job_fifo, job);
|
||||
|
||||
/* unlock the mutex */
|
||||
pthread_mutex_unlock(&job_mutex);
|
||||
|
@ -465,7 +467,9 @@ void httpd(void)
|
|||
for (n = 0; n < n_threads; n++)
|
||||
pthread_join(threads[n], NULL);
|
||||
|
||||
pthread_mutex_lock(&job_mutex);
|
||||
job_fifo = xs_free(job_fifo);
|
||||
pthread_mutex_unlock(&job_mutex);
|
||||
|
||||
srv_log(xs_fmt("httpd stop %s:%d", address, port));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue