summaryrefslogtreecommitdiff
path: root/httpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'httpd.c')
-rw-r--r--httpd.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/httpd.c b/httpd.c
index 381ab08..8c340b8 100644
--- a/httpd.c
+++ b/httpd.c
@@ -197,10 +197,10 @@ void term_handler(int s)
197} 197}
198 198
199 199
200static void *helper_thread(void *arg) 200static void *queue_thread(void *arg)
201/* helper thread (queue management) */ 201/* queue thread (queue management) */
202{ 202{
203 srv_log(xs_fmt("subthread start")); 203 srv_log(xs_fmt("queue thread start"));
204 204
205 while (srv_running) { 205 while (srv_running) {
206 xs *list = user_list(); 206 xs *list = user_list();
@@ -219,12 +219,22 @@ static void *helper_thread(void *arg)
219 sleep(3); 219 sleep(3);
220 } 220 }
221 221
222 srv_log(xs_fmt("subthread stop")); 222 srv_log(xs_fmt("queue thread stop"));
223 223
224 return NULL; 224 return NULL;
225} 225}
226 226
227 227
228static void *connection_thread(void *arg)
229/* connection thread */
230{
231 httpd_connection((FILE *)arg);
232 return NULL;
233}
234
235
236int threaded_connections = 1;
237
228void httpd(void) 238void httpd(void)
229/* starts the server */ 239/* starts the server */
230{ 240{
@@ -249,13 +259,19 @@ void httpd(void)
249 259
250 srv_log(xs_fmt("httpd start %s:%d", address, port)); 260 srv_log(xs_fmt("httpd start %s:%d", address, port));
251 261
252 pthread_create(&htid, NULL, helper_thread, NULL); 262 pthread_create(&htid, NULL, queue_thread, NULL);
253 263
254 if (setjmp(on_break) == 0) { 264 if (setjmp(on_break) == 0) {
255 for (;;) { 265 for (;;) {
256 FILE *f = xs_socket_accept(rs); 266 FILE *f = xs_socket_accept(rs);
257 267
258 httpd_connection(f); 268 if (threaded_connections) {
269 pthread_t cth;
270
271 pthread_create(&cth, NULL, connection_thread, f);
272 }
273 else
274 httpd_connection(f);
259 } 275 }
260 } 276 }
261 277