diff options
| author | 2024-01-08 08:38:25 +0100 | |
|---|---|---|
| committer | 2024-01-08 08:38:25 +0100 | |
| commit | b401cd23ff43a4afdcb3fad85f8c642680a82e95 (patch) | |
| tree | 1e5351817050c92188c88e4e6c075350d994fb38 /httpd.c | |
| parent | Non-important variable renaming. (diff) | |
| download | snac2-b401cd23ff43a4afdcb3fad85f8c642680a82e95.tar.gz snac2-b401cd23ff43a4afdcb3fad85f8c642680a82e95.tar.xz snac2-b401cd23ff43a4afdcb3fad85f8c642680a82e95.zip | |
Added some state flags for threads.
Diffstat (limited to 'httpd.c')
| -rw-r--r-- | httpd.c | 16 |
1 files changed, 14 insertions, 2 deletions
| @@ -506,9 +506,9 @@ static void *job_thread(void *arg) | |||
| 506 | for (;;) { | 506 | for (;;) { |
| 507 | xs *job = NULL; | 507 | xs *job = NULL; |
| 508 | 508 | ||
| 509 | job_wait(&job); | 509 | p_state->th_state[pid] = THST_WAIT; |
| 510 | 510 | ||
| 511 | srv_debug(2, xs_fmt("job thread %d wake up", pid)); | 511 | job_wait(&job); |
| 512 | 512 | ||
| 513 | if (job == NULL) /* corrupted message? */ | 513 | if (job == NULL) /* corrupted message? */ |
| 514 | continue; | 514 | continue; |
| @@ -520,6 +520,8 @@ static void *job_thread(void *arg) | |||
| 520 | /* it's a socket */ | 520 | /* it's a socket */ |
| 521 | FILE *f = NULL; | 521 | FILE *f = NULL; |
| 522 | 522 | ||
| 523 | p_state->th_state[pid] = THST_IN; | ||
| 524 | |||
| 523 | xs_data_get(&f, job); | 525 | xs_data_get(&f, job); |
| 524 | 526 | ||
| 525 | if (f != NULL) | 527 | if (f != NULL) |
| @@ -527,10 +529,14 @@ static void *job_thread(void *arg) | |||
| 527 | } | 529 | } |
| 528 | else { | 530 | else { |
| 529 | /* it's a q_item */ | 531 | /* it's a q_item */ |
| 532 | p_state->th_state[pid] = THST_OUT; | ||
| 533 | |||
| 530 | process_queue_item(job); | 534 | process_queue_item(job); |
| 531 | } | 535 | } |
| 532 | } | 536 | } |
| 533 | 537 | ||
| 538 | p_state->th_state[pid] = THST_STOP; | ||
| 539 | |||
| 534 | srv_debug(1, xs_fmt("job thread %d stopped", pid)); | 540 | srv_debug(1, xs_fmt("job thread %d stopped", pid)); |
| 535 | 541 | ||
| 536 | return NULL; | 542 | return NULL; |
| @@ -556,6 +562,8 @@ static void *background_thread(void *arg) | |||
| 556 | time_t t; | 562 | time_t t; |
| 557 | int cnt = 0; | 563 | int cnt = 0; |
| 558 | 564 | ||
| 565 | p_state->th_state[0] = THST_IN; | ||
| 566 | |||
| 559 | { | 567 | { |
| 560 | xs *list = user_list(); | 568 | xs *list = user_list(); |
| 561 | char *p, *uid; | 569 | char *p, *uid; |
| @@ -588,6 +596,8 @@ static void *background_thread(void *arg) | |||
| 588 | if (cnt == 0) { | 596 | if (cnt == 0) { |
| 589 | /* sleep 3 seconds */ | 597 | /* sleep 3 seconds */ |
| 590 | 598 | ||
| 599 | p_state->th_state[0] = THST_WAIT; | ||
| 600 | |||
| 591 | #ifdef USE_POLL_FOR_SLEEP | 601 | #ifdef USE_POLL_FOR_SLEEP |
| 592 | poll(NULL, 0, 3 * 1000); | 602 | poll(NULL, 0, 3 * 1000); |
| 593 | #else | 603 | #else |
| @@ -603,6 +613,8 @@ static void *background_thread(void *arg) | |||
| 603 | } | 613 | } |
| 604 | } | 614 | } |
| 605 | 615 | ||
| 616 | p_state->th_state[0] = THST_STOP; | ||
| 617 | |||
| 606 | srv_log(xs_fmt("background thread stopped")); | 618 | srv_log(xs_fmt("background thread stopped")); |
| 607 | 619 | ||
| 608 | return NULL; | 620 | return NULL; |