diff options
| author | 2023-03-02 12:38:02 +0100 | |
|---|---|---|
| committer | 2023-03-02 12:38:02 +0100 | |
| commit | 5036cb5e1134d99c967f0de5057801a9b0af96d9 (patch) | |
| tree | f2bb1aa9cd47ddce5d99c93ee3b518b76986a9e0 /httpd.c | |
| parent | Show a bigger piece of a connection error. (diff) | |
| download | snac2-5036cb5e1134d99c967f0de5057801a9b0af96d9.tar.gz snac2-5036cb5e1134d99c967f0de5057801a9b0af96d9.tar.xz snac2-5036cb5e1134d99c967f0de5057801a9b0af96d9.zip | |
Connection jobs are treated as urgent.
Diffstat (limited to 'httpd.c')
| -rw-r--r-- | httpd.c | 16 |
1 files changed, 10 insertions, 6 deletions
| @@ -262,7 +262,7 @@ int job_fifo_ready(void) | |||
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | 264 | ||
| 265 | void job_post(const xs_val *job) | 265 | void job_post(const xs_val *job, int urgent) |
| 266 | /* posts a job for the threads to process it */ | 266 | /* posts a job for the threads to process it */ |
| 267 | { | 267 | { |
| 268 | if (job != NULL) { | 268 | if (job != NULL) { |
| @@ -270,8 +270,12 @@ void job_post(const xs_val *job) | |||
| 270 | pthread_mutex_lock(&job_mutex); | 270 | pthread_mutex_lock(&job_mutex); |
| 271 | 271 | ||
| 272 | /* add to the fifo */ | 272 | /* add to the fifo */ |
| 273 | if (job_fifo != NULL) | 273 | if (job_fifo != NULL) { |
| 274 | job_fifo = xs_list_append(job_fifo, job); | 274 | if (urgent) |
| 275 | job_fifo = xs_list_insert(job_fifo, 0, job); | ||
| 276 | else | ||
| 277 | job_fifo = xs_list_append(job_fifo, job); | ||
| 278 | } | ||
| 275 | 279 | ||
| 276 | /* unlock the mutex */ | 280 | /* unlock the mutex */ |
| 277 | pthread_mutex_unlock(&job_mutex); | 281 | pthread_mutex_unlock(&job_mutex); |
| @@ -386,7 +390,7 @@ static void *background_thread(void *arg) | |||
| 386 | 390 | ||
| 387 | xs *q_item = xs_dict_new(); | 391 | xs *q_item = xs_dict_new(); |
| 388 | q_item = xs_dict_append(q_item, "type", "purge"); | 392 | q_item = xs_dict_append(q_item, "type", "purge"); |
| 389 | job_post(q_item); | 393 | job_post(q_item, 0); |
| 390 | } | 394 | } |
| 391 | 395 | ||
| 392 | if (cnt == 0) { | 396 | if (cnt == 0) { |
| @@ -485,7 +489,7 @@ void httpd(void) | |||
| 485 | 489 | ||
| 486 | if (f != NULL) { | 490 | if (f != NULL) { |
| 487 | xs *job = xs_data_new(&f, sizeof(FILE *)); | 491 | xs *job = xs_data_new(&f, sizeof(FILE *)); |
| 488 | job_post(job); | 492 | job_post(job, 1); |
| 489 | } | 493 | } |
| 490 | else | 494 | else |
| 491 | break; | 495 | break; |
| @@ -496,7 +500,7 @@ void httpd(void) | |||
| 496 | 500 | ||
| 497 | /* send as many empty jobs as working threads */ | 501 | /* send as many empty jobs as working threads */ |
| 498 | for (n = 1; n < n_threads; n++) | 502 | for (n = 1; n < n_threads; n++) |
| 499 | job_post(NULL); | 503 | job_post(NULL, 0); |
| 500 | 504 | ||
| 501 | /* wait for all the threads to exit */ | 505 | /* wait for all the threads to exit */ |
| 502 | for (n = 0; n < n_threads; n++) | 506 | for (n = 0; n < n_threads; n++) |