commit b16ceaf

default  ·  2023-02-06 18:29:22 +0000 UTC
parent 8b465a5
Identify the job threads by number.
1 files changed,  +6, -6
+6, -6
 1@@ -368,16 +368,16 @@ void job_wait(xs_val **job)
 2 static void *job_thread(void *arg)
 3 /* job thread */
 4 {
 5-    int pid = pthread_self();
 6+    long long pid = (long long)arg;
 7 
 8-    srv_debug(0, xs_fmt("job thread %x started", pid));
 9+    srv_debug(0, xs_fmt("job thread %ld started", pid));
10 
11     for (;;) {
12         xs *job = NULL;
13 
14         job_wait(&job);
15 
16-        srv_debug(0, xs_fmt("job thread %x wake up", pid));
17+        srv_debug(0, xs_fmt("job thread %ld wake up", pid));
18 
19         if (job == NULL)
20             break;
21@@ -393,7 +393,7 @@ static void *job_thread(void *arg)
22         }
23     }
24 
25-    srv_debug(0, xs_fmt("job thread %x stopped", pid));
26+    srv_debug(0, xs_fmt("job thread %ld stopped", pid));
27 
28     return NULL;
29 }
30@@ -405,7 +405,7 @@ void httpd(void)
31     char *address;
32     int port;
33     int rs;
34-    pthread_t threads[MAX_THREADS];
35+    pthread_t threads[MAX_THREADS] = {0};
36     int n_threads = 0;
37     int n;
38 
39@@ -448,7 +448,7 @@ void httpd(void)
40 
41     /* the rest of threads are for job processing */
42     for (n = 1; n < n_threads; n++)
43-        pthread_create(&threads[n], NULL, job_thread, NULL);
44+        pthread_create(&threads[n], NULL, job_thread, (void *)(long long)n);
45 
46     if (setjmp(on_break) == 0) {
47         for (;;) {