aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/daemon.c')
-rw-r--r--src/daemon/daemon.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index 490317ea..58e2e058 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -319,17 +319,22 @@ MHD_cleanup_sessions(struct MHD_Daemon * daemon) {
319/** 319/**
320 * Main select call. 320 * Main select call.
321 * 321 *
322 * @param may_block YES if blocking, NO if non-blocking
322 * @return MHD_NO on serious errors, MHD_YES on success 323 * @return MHD_NO on serious errors, MHD_YES on success
323 */ 324 */
324static int 325static int
325MHD_select(struct MHD_Daemon * daemon) { 326MHD_select(struct MHD_Daemon * daemon,
327 int may_block) {
326 struct MHD_Session * pos; 328 struct MHD_Session * pos;
327 int num_ready; 329 int num_ready;
328 fd_set rs; 330 fd_set rs;
329 fd_set ws; 331 fd_set ws;
330 fd_set es; 332 fd_set es;
331 int max; 333 int max;
334 struct timeval timeout;
332 335
336 timeout.tv_sec = 0;
337 timeout.tv_usec = 0;
333 if(daemon == NULL) 338 if(daemon == NULL)
334 abort(); 339 abort();
335 FD_ZERO(&rs); 340 FD_ZERO(&rs);
@@ -354,7 +359,7 @@ MHD_select(struct MHD_Daemon * daemon) {
354 &rs, 359 &rs,
355 &ws, 360 &ws,
356 &es, 361 &es,
357 NULL); 362 may_block == MHD_NO ? &timeout : NULL);
358 if (num_ready < 0) { 363 if (num_ready < 0) {
359 if (errno == EINTR) 364 if (errno == EINTR)
360 return MHD_YES; 365 return MHD_YES;
@@ -397,7 +402,7 @@ MHD_run(struct MHD_Daemon * daemon) {
397 (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || 402 (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) ||
398 (0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) ) 403 (0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) )
399 return MHD_NO; 404 return MHD_NO;
400 MHD_select(daemon); 405 MHD_select(daemon, MHD_NO);
401 MHD_cleanup_sessions(daemon); 406 MHD_cleanup_sessions(daemon);
402 return MHD_YES; 407 return MHD_YES;
403} 408}
@@ -411,7 +416,7 @@ static void *
411MHD_select_thread(void * cls) { 416MHD_select_thread(void * cls) {
412 struct MHD_Daemon * daemon = cls; 417 struct MHD_Daemon * daemon = cls;
413 while (daemon->shutdown == 0) { 418 while (daemon->shutdown == 0) {
414 MHD_select(daemon); 419 MHD_select(daemon, MHD_YES);
415 MHD_cleanup_sessions(daemon); 420 MHD_cleanup_sessions(daemon);
416 } 421 }
417 return NULL; 422 return NULL;