summaryrefslogtreecommitdiff
path: root/httpd.c
diff options
context:
space:
mode:
authorGravatar default2023-02-06 08:44:00 +0100
committerGravatar default2023-02-06 08:44:00 +0100
commit307e0aa27a009100a735653b8928405286007ee5 (patch)
treeb9d81438082ddbd002d66bb86cbe91049163c7d7 /httpd.c
parentUpdated RELEASE_NOTES. (diff)
downloadsnac2-307e0aa27a009100a735653b8928405286007ee5.tar.gz
snac2-307e0aa27a009100a735653b8928405286007ee5.tar.xz
snac2-307e0aa27a009100a735653b8928405286007ee5.zip
Input connections cannot be non-threaded.
Diffstat (limited to 'httpd.c')
-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)
249} 249}
250 250
251 251
252static void *queue_thread(void *arg) 252static void *background_thread(void *arg)
253/* queue thread (queue management) */ 253/* background thread (queue management and other things) */
254{ 254{
255 pthread_mutex_t dummy_mutex = PTHREAD_MUTEX_INITIALIZER; 255 pthread_mutex_t dummy_mutex = PTHREAD_MUTEX_INITIALIZER;
256 pthread_cond_t dummy_cond = PTHREAD_COND_INITIALIZER; 256 pthread_cond_t dummy_cond = PTHREAD_COND_INITIALIZER;
@@ -259,7 +259,7 @@ static void *queue_thread(void *arg)
259 /* first purge time */ 259 /* first purge time */
260 purge_time = time(NULL) + 10 * 60; 260 purge_time = time(NULL) + 10 * 60;
261 261
262 srv_log(xs_fmt("queue thread start")); 262 srv_log(xs_fmt("background thread started"));
263 263
264 while (srv_running) { 264 while (srv_running) {
265 time_t t; 265 time_t t;
@@ -304,7 +304,7 @@ static void *queue_thread(void *arg)
304 pthread_mutex_unlock(&dummy_mutex); 304 pthread_mutex_unlock(&dummy_mutex);
305 } 305 }
306 306
307 srv_log(xs_fmt("queue thread stop")); 307 srv_log(xs_fmt("background thread stopped"));
308 308
309 return NULL; 309 return NULL;
310} 310}
@@ -318,8 +318,6 @@ static void *connection_thread(void *arg)
318} 318}
319 319
320 320
321int threaded_connections = 1;
322
323void httpd(void) 321void httpd(void)
324/* starts the server */ 322/* starts the server */
325{ 323{
@@ -344,20 +342,16 @@ void httpd(void)
344 342
345 srv_log(xs_fmt("httpd start %s:%d %s", address, port, USER_AGENT)); 343 srv_log(xs_fmt("httpd start %s:%d %s", address, port, USER_AGENT));
346 344
347 pthread_create(&htid, NULL, queue_thread, NULL); 345 pthread_create(&htid, NULL, background_thread, NULL);
348 346
349 if (setjmp(on_break) == 0) { 347 if (setjmp(on_break) == 0) {
350 for (;;) { 348 for (;;) {
351 FILE *f = xs_socket_accept(rs); 349 FILE *f = xs_socket_accept(rs);
352 350
353 if (threaded_connections) { 351 pthread_t cth;
354 pthread_t cth;
355 352
356 pthread_create(&cth, NULL, connection_thread, f); 353 pthread_create(&cth, NULL, connection_thread, f);
357 pthread_detach(cth); 354 pthread_detach(cth);
358 }
359 else
360 httpd_connection(f);
361 } 355 }
362 } 356 }
363 357