snac2

Fork of https://codeberg.org/grunfink/snac2
git clone https://git.inz.fi/snac2
Log | Files | Refs | README | LICENSE

commit aa1524be717faaee42181e9b684c6346e5e4291b
parent 3d1f6049e2e91edecaf99d49624f0826d0ca945d
Author: default <nobody@localhost>
Date:   Sun,  7 Jan 2024 11:13:59 +0100

Better behaviour on broken queue items.

Diffstat:
Mhttpd.c | 20+++++++++++++-------
Mxs_version.h | 2+-
2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/httpd.c b/httpd.c @@ -451,14 +451,17 @@ void job_post(const xs_val *job, int urgent) job_fifo = xs_list_append(job_fifo, job); p_stat->job_fifo_size++; + + srv_debug(2, xs_fmt( + "job_fifo sizes: %d %08x", p_stat->job_fifo_size, xs_size(job_fifo))); } /* unlock the mutex */ pthread_mutex_unlock(&job_mutex); - } - /* ask for someone to attend it */ - sem_post(job_sem); + /* ask for someone to attend it */ + sem_post(job_sem); + } } @@ -502,9 +505,12 @@ static void *job_thread(void *arg) srv_debug(2, xs_fmt("job thread %d wake up", pid)); - if (job == NULL) - break; + if (job == NULL) /* corrupted message? */ + continue; + if (xs_type(job) == XSTYPE_FALSE) /* special message: exit */ + break; + else if (xs_type(job) == XSTYPE_DATA) { /* it's a socket */ FILE *f = NULL; @@ -703,9 +709,9 @@ void httpd(void) p_stat->srv_running = 0; - /* send as many empty jobs as working threads */ + /* send as many exit jobs as working threads */ for (n = 1; n < p_stat->n_threads; n++) - job_post(NULL, 0); + job_post(xs_stock_false, 0); /* wait for all the threads to exit */ for (n = 0; n < p_stat->n_threads; n++) diff --git a/xs_version.h b/xs_version.h @@ -1 +1 @@ -/* 3e906b28aaa910cd79dd5eb1d88fda82201d28de 2024-01-04T09:20:12+01:00 */ +/* 72caf9fc60c0b90f39a3c62b238d1c9663d109bc 2024-01-07T09:26:08+01:00 */