diff options
author | Christian Grothoff <christian@grothoff.org> | 2007-06-14 00:26:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2007-06-14 00:26:06 +0000 |
commit | 3d39029f14a63af8cd26b1b0c9000cecea97931c (patch) | |
tree | 290e417d8c23fb8b2051a4273c676b0f357da5e3 | |
parent | b7054096a4e58009d7eddbda083762883213f937 (diff) |
fixes
-rw-r--r-- | src/daemon/daemon.c | 20 | ||||
-rw-r--r-- | src/daemon/daemontest1.c | 16 | ||||
-rw-r--r-- | src/daemon/response.c | 2 | ||||
-rw-r--r-- | src/daemon/session.c | 2 |
4 files changed, 25 insertions, 15 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 657afb23..33f048ed 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c @@ -276,6 +276,7 @@ MHD_cleanup_sessions(struct MHD_Daemon * daemon) { struct MHD_Session * pos; struct MHD_Session * prev; struct MHD_HTTP_Header * hpos; + void * unused; pos = daemon->connections; prev = NULL; @@ -285,6 +286,8 @@ MHD_cleanup_sessions(struct MHD_Daemon * daemon) { daemon->connections = pos->next; else prev->next = pos->next; + if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) + pthread_join(pos->pid, &unused); free(pos->addr); if (pos->url != NULL) free(pos->url); @@ -299,6 +302,7 @@ MHD_cleanup_sessions(struct MHD_Daemon * daemon) { pos->headers_received = hpos->next; free(hpos->header); free(hpos->value); + free(hpos); } if (pos->response != NULL) MHD_destroy_response(pos->response); @@ -337,6 +341,7 @@ MHD_select(struct MHD_Daemon * daemon, fd_set es; int max; struct timeval timeout; + int ds; timeout.tv_sec = 0; timeout.tv_usec = 0; @@ -373,16 +378,22 @@ MHD_select(struct MHD_Daemon * daemon, strerror(errno)); return MHD_NO; } - if (FD_ISSET(daemon->socket_fd, + ds = daemon->socket_fd; + if (ds == -1) + return MHD_YES; + if (FD_ISSET(ds, &rs)) MHD_accept_connection(daemon); if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) { /* do not have a thread per connection, process all connections now */ pos = daemon->connections; while (pos != NULL) { - if (FD_ISSET(pos->socket_fd, &rs)) + ds = pos->socket_fd; + if (ds == -1) + continue; + if (FD_ISSET(ds, &rs)) MHD_session_handle_read(pos); - if (FD_ISSET(pos->socket_fd, &ws)) + if (FD_ISSET(ds, &ws)) MHD_session_handle_write(pos); pos = pos->next; } @@ -542,9 +553,6 @@ MHD_stop_daemon(struct MHD_Daemon * daemon) { close(daemon->connections->socket_fd); daemon->connections->socket_fd = -1; } - if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) - pthread_join(daemon->connections->pid, &unused); - MHD_cleanup_sessions(daemon); } free(daemon); diff --git a/src/daemon/daemontest1.c b/src/daemon/daemontest1.c index 77abd6c3..4c2103f1 100644 --- a/src/daemon/daemontest1.c +++ b/src/daemon/daemontest1.c @@ -131,14 +131,14 @@ static int testInternalGet() { return 2; } curl_easy_cleanup(c); - if (cbc.pos != strlen("hello_world")) { + if (cbc.pos != strlen("/hello_world")) { MHD_stop_daemon(d); return 4; } - if (0 != strncmp("hello_world", + if (0 != strncmp("/hello_world", cbc.buf, - strlen("hello_world"))) { + strlen("/hello_world"))) { MHD_stop_daemon(d); return 8; } @@ -190,16 +190,18 @@ static int testMultithreadedGet() { curl_easy_setopt(c, CURLOPT_NOSIGNAL, 1); - if (CURLE_OK != curl_easy_perform(c)) + if (CURLE_OK != curl_easy_perform(c)) { + MHD_stop_daemon(d); return 32; + } curl_easy_cleanup(c); - if (cbc.pos != strlen("hello_world")) { + if (cbc.pos != strlen("/hello_world")) { MHD_stop_daemon(d); return 64; } - if (0 != strncmp("hello_world", + if (0 != strncmp("/hello_world", cbc.buf, - strlen("hello_world"))) { + strlen("/hello_world"))) { MHD_stop_daemon(d); return 128; } diff --git a/src/daemon/response.c b/src/daemon/response.c index 0c4b1de4..747932a2 100644 --- a/src/daemon/response.c +++ b/src/daemon/response.c @@ -250,6 +250,8 @@ MHD_destroy_response(struct MHD_Response * response) { } pthread_mutex_unlock(&response->mutex); pthread_mutex_destroy(&response->mutex); + if (response->crfc != NULL) + response->crfc(response->crc_cls); while (response->first_header != NULL) { pos = response->first_header; response->first_header = pos->next; diff --git a/src/daemon/session.c b/src/daemon/session.c index 9cba0d28..828b91a1 100644 --- a/src/daemon/session.c +++ b/src/daemon/session.c @@ -275,8 +275,6 @@ MHD_parse_session_headers(struct MHD_Session * session) { session->headers_received = hdr; } /* FIXME: here: find cookie header and parse that! */ - if (session->bodyReceived == 0) - return; return; DIE: close(session->socket_fd); |