snac2

Fork of https://codeberg.org/grunfink/snac2
git clone https://git.inz.fi/snac2
Log | Files | Refs | README | LICENSE

commit b16ceafdde7fc010c5f0effb3b4a5da9f5367f5f
parent 8b465a586d7d8e6e10e2c69e91767e0d1ff9477a
Author: default <nobody@localhost>
Date:   Mon,  6 Feb 2023 19:29:22 +0100

Identify the job threads by number.

Diffstat:
Mhttpd.c | 12++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/httpd.c b/httpd.c @@ -368,16 +368,16 @@ void job_wait(xs_val **job) static void *job_thread(void *arg) /* job thread */ { - int pid = pthread_self(); + long long pid = (long long)arg; - srv_debug(0, xs_fmt("job thread %x started", pid)); + srv_debug(0, xs_fmt("job thread %ld started", pid)); for (;;) { xs *job = NULL; job_wait(&job); - srv_debug(0, xs_fmt("job thread %x wake up", pid)); + srv_debug(0, xs_fmt("job thread %ld wake up", pid)); if (job == NULL) break; @@ -393,7 +393,7 @@ static void *job_thread(void *arg) } } - srv_debug(0, xs_fmt("job thread %x stopped", pid)); + srv_debug(0, xs_fmt("job thread %ld stopped", pid)); return NULL; } @@ -405,7 +405,7 @@ void httpd(void) char *address; int port; int rs; - pthread_t threads[MAX_THREADS]; + pthread_t threads[MAX_THREADS] = {0}; int n_threads = 0; int n; @@ -448,7 +448,7 @@ void httpd(void) /* the rest of threads are for job processing */ for (n = 1; n < n_threads; n++) - pthread_create(&threads[n], NULL, job_thread, NULL); + pthread_create(&threads[n], NULL, job_thread, (void *)(long long)n); if (setjmp(on_break) == 0) { for (;;) {