summaryrefslogtreecommitdiff
path: root/httpd.c
diff options
context:
space:
mode:
authorGravatar default2024-01-07 11:13:59 +0100
committerGravatar default2024-01-07 11:13:59 +0100
commitaa1524be717faaee42181e9b684c6346e5e4291b (patch)
tree6f30fcfa7b1e209d1381e918e982d7247b076886 /httpd.c
parentBackport from xs. (diff)
downloadpenes-snac2-aa1524be717faaee42181e9b684c6346e5e4291b.tar.gz
penes-snac2-aa1524be717faaee42181e9b684c6346e5e4291b.tar.xz
penes-snac2-aa1524be717faaee42181e9b684c6346e5e4291b.zip
Better behaviour on broken queue items.
Diffstat (limited to 'httpd.c')
-rw-r--r--httpd.c20
1 files changed, 13 insertions, 7 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)
451 job_fifo = xs_list_append(job_fifo, job); 451 job_fifo = xs_list_append(job_fifo, job);
452 452
453 p_stat->job_fifo_size++; 453 p_stat->job_fifo_size++;
454
455 srv_debug(2, xs_fmt(
456 "job_fifo sizes: %d %08x", p_stat->job_fifo_size, xs_size(job_fifo)));
454 } 457 }
455 458
456 /* unlock the mutex */ 459 /* unlock the mutex */
457 pthread_mutex_unlock(&job_mutex); 460 pthread_mutex_unlock(&job_mutex);
458 }
459 461
460 /* ask for someone to attend it */ 462 /* ask for someone to attend it */
461 sem_post(job_sem); 463 sem_post(job_sem);
464 }
462} 465}
463 466
464 467
@@ -502,9 +505,12 @@ static void *job_thread(void *arg)
502 505
503 srv_debug(2, xs_fmt("job thread %d wake up", pid)); 506 srv_debug(2, xs_fmt("job thread %d wake up", pid));
504 507
505 if (job == NULL) 508 if (job == NULL) /* corrupted message? */
506 break; 509 continue;
507 510
511 if (xs_type(job) == XSTYPE_FALSE) /* special message: exit */
512 break;
513 else
508 if (xs_type(job) == XSTYPE_DATA) { 514 if (xs_type(job) == XSTYPE_DATA) {
509 /* it's a socket */ 515 /* it's a socket */
510 FILE *f = NULL; 516 FILE *f = NULL;
@@ -703,9 +709,9 @@ void httpd(void)
703 709
704 p_stat->srv_running = 0; 710 p_stat->srv_running = 0;
705 711
706 /* send as many empty jobs as working threads */ 712 /* send as many exit jobs as working threads */
707 for (n = 1; n < p_stat->n_threads; n++) 713 for (n = 1; n < p_stat->n_threads; n++)
708 job_post(NULL, 0); 714 job_post(xs_stock_false, 0);
709 715
710 /* wait for all the threads to exit */ 716 /* wait for all the threads to exit */
711 for (n = 0; n < p_stat->n_threads; n++) 717 for (n = 0; n < p_stat->n_threads; n++)