summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-02-06 08:44:00 +0100
committerdefault <nobody@localhost>2023-02-06 08:44:00 +0100
commit307e0aa27a009100a735653b8928405286007ee5 (patch)
treeb9d81438082ddbd002d66bb86cbe91049163c7d7
parent9c98b596e9c9c0a638611f50afe0567c7f4db400 (diff)
Input connections cannot be non-threaded.
-rw-r--r--httpd.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/httpd.c b/httpd.c
index 7932982..37b4f02 100644
--- a/httpd.c
+++ b/httpd.c
@@ -249,8 +249,8 @@ static void *purge_thread(void *arg)
}
-static void *queue_thread(void *arg)
-/* queue thread (queue management) */
+static void *background_thread(void *arg)
+/* background thread (queue management and other things) */
{
pthread_mutex_t dummy_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t dummy_cond = PTHREAD_COND_INITIALIZER;
@@ -259,7 +259,7 @@ static void *queue_thread(void *arg)
/* first purge time */
purge_time = time(NULL) + 10 * 60;
- srv_log(xs_fmt("queue thread start"));
+ srv_log(xs_fmt("background thread started"));
while (srv_running) {
time_t t;
@@ -304,7 +304,7 @@ static void *queue_thread(void *arg)
pthread_mutex_unlock(&dummy_mutex);
}
- srv_log(xs_fmt("queue thread stop"));
+ srv_log(xs_fmt("background thread stopped"));
return NULL;
}
@@ -318,8 +318,6 @@ static void *connection_thread(void *arg)
}
-int threaded_connections = 1;
-
void httpd(void)
/* starts the server */
{
@@ -344,20 +342,16 @@ void httpd(void)
srv_log(xs_fmt("httpd start %s:%d %s", address, port, USER_AGENT));
- pthread_create(&htid, NULL, queue_thread, NULL);
+ pthread_create(&htid, NULL, background_thread, NULL);
if (setjmp(on_break) == 0) {
for (;;) {
FILE *f = xs_socket_accept(rs);
- if (threaded_connections) {
- pthread_t cth;
+ pthread_t cth;
- pthread_create(&cth, NULL, connection_thread, f);
- pthread_detach(cth);
- }
- else
- httpd_connection(f);
+ pthread_create(&cth, NULL, connection_thread, f);
+ pthread_detach(cth);
}
}