This commit is contained in:
Christian Grothoff
2007-06-13 22:16:26 +00:00
parent 53918b01dc
commit b6a83f0007
2 changed files with 17 additions and 9 deletions
+9 -4
View File
@@ -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;
+8 -5
View File
@@ -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;
}