Identify the job threads by number.

This commit is contained in:
default 2023-02-06 19:29:22 +01:00
parent 8b465a586d
commit b16ceafdde

12
httpd.c
View File

@ -368,16 +368,16 @@ void job_wait(xs_val **job)
static void *job_thread(void *arg) static void *job_thread(void *arg)
/* job thread */ /* 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 (;;) { for (;;) {
xs *job = NULL; xs *job = NULL;
job_wait(&job); 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) if (job == NULL)
break; 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; return NULL;
} }
@ -405,7 +405,7 @@ void httpd(void)
char *address; char *address;
int port; int port;
int rs; int rs;
pthread_t threads[MAX_THREADS]; pthread_t threads[MAX_THREADS] = {0};
int n_threads = 0; int n_threads = 0;
int n; int n;
@ -448,7 +448,7 @@ void httpd(void)
/* the rest of threads are for job processing */ /* the rest of threads are for job processing */
for (n = 1; n < n_threads; n++) 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) { if (setjmp(on_break) == 0) {
for (;;) { for (;;) {