mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-15 01:55:03 +00:00
Input connections cannot be non-threaded.
This commit is contained in:
parent
9c98b596e9
commit
307e0aa27a
1 changed files with 8 additions and 14 deletions
22
httpd.c
22
httpd.c
|
@ -249,8 +249,8 @@ static void *purge_thread(void *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *queue_thread(void *arg)
|
static void *background_thread(void *arg)
|
||||||
/* queue thread (queue management) */
|
/* background thread (queue management and other things) */
|
||||||
{
|
{
|
||||||
pthread_mutex_t dummy_mutex = PTHREAD_MUTEX_INITIALIZER;
|
pthread_mutex_t dummy_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
pthread_cond_t dummy_cond = PTHREAD_COND_INITIALIZER;
|
pthread_cond_t dummy_cond = PTHREAD_COND_INITIALIZER;
|
||||||
|
@ -259,7 +259,7 @@ static void *queue_thread(void *arg)
|
||||||
/* first purge time */
|
/* first purge time */
|
||||||
purge_time = time(NULL) + 10 * 60;
|
purge_time = time(NULL) + 10 * 60;
|
||||||
|
|
||||||
srv_log(xs_fmt("queue thread start"));
|
srv_log(xs_fmt("background thread started"));
|
||||||
|
|
||||||
while (srv_running) {
|
while (srv_running) {
|
||||||
time_t t;
|
time_t t;
|
||||||
|
@ -304,7 +304,7 @@ static void *queue_thread(void *arg)
|
||||||
pthread_mutex_unlock(&dummy_mutex);
|
pthread_mutex_unlock(&dummy_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
srv_log(xs_fmt("queue thread stop"));
|
srv_log(xs_fmt("background thread stopped"));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -318,8 +318,6 @@ static void *connection_thread(void *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int threaded_connections = 1;
|
|
||||||
|
|
||||||
void httpd(void)
|
void httpd(void)
|
||||||
/* starts the server */
|
/* starts the server */
|
||||||
{
|
{
|
||||||
|
@ -344,20 +342,16 @@ void httpd(void)
|
||||||
|
|
||||||
srv_log(xs_fmt("httpd start %s:%d %s", address, port, USER_AGENT));
|
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) {
|
if (setjmp(on_break) == 0) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
FILE *f = xs_socket_accept(rs);
|
FILE *f = xs_socket_accept(rs);
|
||||||
|
|
||||||
if (threaded_connections) {
|
pthread_t cth;
|
||||||
pthread_t cth;
|
|
||||||
|
|
||||||
pthread_create(&cth, NULL, connection_thread, f);
|
pthread_create(&cth, NULL, connection_thread, f);
|
||||||
pthread_detach(cth);
|
pthread_detach(cth);
|
||||||
}
|
|
||||||
else
|
|
||||||
httpd_connection(f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue