summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2024-01-07 11:13:59 +0100
committerdefault <nobody@localhost>2024-01-07 11:13:59 +0100
commitaa1524be717faaee42181e9b684c6346e5e4291b (patch)
tree6f30fcfa7b1e209d1381e918e982d7247b076886
parent3d1f6049e2e91edecaf99d49624f0826d0ca945d (diff)
Better behaviour on broken queue items.
-rw-r--r--httpd.c20
-rw-r--r--xs_version.h2
2 files changed, 14 insertions, 8 deletions
diff --git a/httpd.c b/httpd.c
index 65bd467..7e71049 100644
--- 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
index 8d47ae4..c592d93 100644
--- 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 */