diff options
| author | 2024-01-07 11:13:59 +0100 | |
|---|---|---|
| committer | 2024-01-07 11:13:59 +0100 | |
| commit | aa1524be717faaee42181e9b684c6346e5e4291b (patch) | |
| tree | 6f30fcfa7b1e209d1381e918e982d7247b076886 | |
| parent | Backport from xs. (diff) | |
| download | snac2-aa1524be717faaee42181e9b684c6346e5e4291b.tar.gz snac2-aa1524be717faaee42181e9b684c6346e5e4291b.tar.xz snac2-aa1524be717faaee42181e9b684c6346e5e4291b.zip | |
Better behaviour on broken queue items.
Diffstat (limited to '')
| -rw-r--r-- | httpd.c | 20 | ||||
| -rw-r--r-- | xs_version.h | 2 |
2 files changed, 14 insertions, 8 deletions
| @@ -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++) |
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 */ | ||