diff options
author | Christian Grothoff <christian@grothoff.org> | 2007-06-13 22:16:26 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2007-06-13 22:16:26 +0000 |
commit | b6a83f00076a84e9322323031734cadf2930e159 (patch) | |
tree | 3966d328741bf9d10753186bb229031ccacfca66 | |
parent | 53918b01dc591cc732312088712c54ef86386bbe (diff) |
fix
-rw-r--r-- | src/daemon/daemon.c | 13 | ||||
-rw-r--r-- | src/daemon/daemontest.c | 13 |
2 files changed, 17 insertions, 9 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) { /** * Main select call. * + * @param may_block YES if blocking, NO if non-blocking * @return MHD_NO on serious errors, MHD_YES on success */ static int -MHD_select(struct MHD_Daemon * daemon) { +MHD_select(struct MHD_Daemon * daemon, + int may_block) { struct MHD_Session * pos; int num_ready; fd_set rs; fd_set ws; fd_set es; int max; + struct timeval timeout; + timeout.tv_sec = 0; + timeout.tv_usec = 0; if(daemon == NULL) abort(); FD_ZERO(&rs); @@ -354,7 +359,7 @@ MHD_select(struct MHD_Daemon * daemon) { &rs, &ws, &es, - NULL); + may_block == MHD_NO ? &timeout : NULL); if (num_ready < 0) { if (errno == EINTR) return MHD_YES; @@ -397,7 +402,7 @@ MHD_run(struct MHD_Daemon * daemon) { (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || (0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) ) return MHD_NO; - MHD_select(daemon); + MHD_select(daemon, MHD_NO); MHD_cleanup_sessions(daemon); return MHD_YES; } @@ -411,7 +416,7 @@ static void * MHD_select_thread(void * cls) { struct MHD_Daemon * daemon = cls; while (daemon->shutdown == 0) { - MHD_select(daemon); + MHD_select(daemon, MHD_YES); MHD_cleanup_sessions(daemon); } return NULL; diff --git a/src/daemon/daemontest.c b/src/daemon/daemontest.c index 38aadbea..3fccce9d 100644 --- a/src/daemon/daemontest.c +++ b/src/daemon/daemontest.c @@ -78,7 +78,7 @@ static int testStartStop() { static int testExternalRun() { struct MHD_Daemon * d; - fd_set read; + fd_set rs; int maxfd; int i; @@ -93,13 +93,16 @@ static int testExternalRun() { return 4; i = 0; while(i < 15) { - MHD_get_fdset(d, &read, &read, &read, &maxfd); + maxfd = 0; + FD_ZERO(&rs); + MHD_get_fdset(d, &rs, &rs, &rs, &maxfd); if (MHD_run(d) == MHD_NO) { MHD_stop_daemon(d); return 8; } i++; } + MHD_stop_daemon(d); return 0; } @@ -114,7 +117,7 @@ static int testThread() { if (d == NULL) return 16; - if (MHD_run(d) == MHD_NO) + if (MHD_run(d) != MHD_NO) return 32; MHD_stop_daemon(d); return 0; @@ -131,8 +134,8 @@ static int testMultithread() { if (d == NULL) return 64; - if (MHD_run(d) == MHD_NO) - return 128; + if (MHD_run(d) != MHD_NO) + return 128; MHD_stop_daemon(d); return 0; } |