commit 307e0aa

default  ·  2023-02-06 07:44:00 +0000 UTC
parent 9c98b59
Input connections cannot be non-threaded.
1 files changed,  +8, -14
+8, -14
 1@@ -249,8 +249,8 @@ static void *purge_thread(void *arg)
 2 }
 3 
 4 
 5-static void *queue_thread(void *arg)
 6-/* queue thread (queue management) */
 7+static void *background_thread(void *arg)
 8+/* background thread (queue management and other things) */
 9 {
10     pthread_mutex_t dummy_mutex = PTHREAD_MUTEX_INITIALIZER;
11     pthread_cond_t  dummy_cond  = PTHREAD_COND_INITIALIZER;
12@@ -259,7 +259,7 @@ static void *queue_thread(void *arg)
13     /* first purge time */
14     purge_time = time(NULL) + 10 * 60;
15 
16-    srv_log(xs_fmt("queue thread start"));
17+    srv_log(xs_fmt("background thread started"));
18 
19     while (srv_running) {
20         time_t t;
21@@ -304,7 +304,7 @@ static void *queue_thread(void *arg)
22         pthread_mutex_unlock(&dummy_mutex);
23     }
24 
25-    srv_log(xs_fmt("queue thread stop"));
26+    srv_log(xs_fmt("background thread stopped"));
27 
28     return NULL;
29 }
30@@ -318,8 +318,6 @@ static void *connection_thread(void *arg)
31 }
32 
33 
34-int threaded_connections = 1;
35-
36 void httpd(void)
37 /* starts the server */
38 {
39@@ -344,20 +342,16 @@ void httpd(void)
40 
41     srv_log(xs_fmt("httpd start %s:%d %s", address, port, USER_AGENT));
42 
43-    pthread_create(&htid, NULL, queue_thread, NULL);
44+    pthread_create(&htid, NULL, background_thread, NULL);
45 
46     if (setjmp(on_break) == 0) {
47         for (;;) {
48             FILE *f = xs_socket_accept(rs);
49 
50-            if (threaded_connections) {
51-                pthread_t cth;
52+            pthread_t cth;
53 
54-                pthread_create(&cth, NULL, connection_thread, f);
55-                pthread_detach(cth);
56-            }
57-            else
58-                httpd_connection(f);
59+            pthread_create(&cth, NULL, connection_thread, f);
60+            pthread_detach(cth);
61         }
62     }
63