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) | |
download | libmicrohttpd-3d39029f14a63af8cd26b1b0c9000cecea97931c.tar.gz libmicrohttpd-3d39029f14a63af8cd26b1b0c9000cecea97931c.zip |
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) { | |||
276 | struct MHD_Session * pos; | 276 | struct MHD_Session * pos; |
277 | struct MHD_Session * prev; | 277 | struct MHD_Session * prev; |
278 | struct MHD_HTTP_Header * hpos; | 278 | struct MHD_HTTP_Header * hpos; |
279 | void * unused; | ||
279 | 280 | ||
280 | pos = daemon->connections; | 281 | pos = daemon->connections; |
281 | prev = NULL; | 282 | prev = NULL; |
@@ -285,6 +286,8 @@ MHD_cleanup_sessions(struct MHD_Daemon * daemon) { | |||
285 | daemon->connections = pos->next; | 286 | daemon->connections = pos->next; |
286 | else | 287 | else |
287 | prev->next = pos->next; | 288 | prev->next = pos->next; |
289 | if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) | ||
290 | pthread_join(pos->pid, &unused); | ||
288 | free(pos->addr); | 291 | free(pos->addr); |
289 | if (pos->url != NULL) | 292 | if (pos->url != NULL) |
290 | free(pos->url); | 293 | free(pos->url); |
@@ -299,6 +302,7 @@ MHD_cleanup_sessions(struct MHD_Daemon * daemon) { | |||
299 | pos->headers_received = hpos->next; | 302 | pos->headers_received = hpos->next; |
300 | free(hpos->header); | 303 | free(hpos->header); |
301 | free(hpos->value); | 304 | free(hpos->value); |
305 | free(hpos); | ||
302 | } | 306 | } |
303 | if (pos->response != NULL) | 307 | if (pos->response != NULL) |
304 | MHD_destroy_response(pos->response); | 308 | MHD_destroy_response(pos->response); |
@@ -337,6 +341,7 @@ MHD_select(struct MHD_Daemon * daemon, | |||
337 | fd_set es; | 341 | fd_set es; |
338 | int max; | 342 | int max; |
339 | struct timeval timeout; | 343 | struct timeval timeout; |
344 | int ds; | ||
340 | 345 | ||
341 | timeout.tv_sec = 0; | 346 | timeout.tv_sec = 0; |
342 | timeout.tv_usec = 0; | 347 | timeout.tv_usec = 0; |
@@ -373,16 +378,22 @@ MHD_select(struct MHD_Daemon * daemon, | |||
373 | strerror(errno)); | 378 | strerror(errno)); |
374 | return MHD_NO; | 379 | return MHD_NO; |
375 | } | 380 | } |
376 | if (FD_ISSET(daemon->socket_fd, | 381 | ds = daemon->socket_fd; |
382 | if (ds == -1) | ||
383 | return MHD_YES; | ||
384 | if (FD_ISSET(ds, | ||
377 | &rs)) | 385 | &rs)) |
378 | MHD_accept_connection(daemon); | 386 | MHD_accept_connection(daemon); |
379 | if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) { | 387 | if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) { |
380 | /* do not have a thread per connection, process all connections now */ | 388 | /* do not have a thread per connection, process all connections now */ |
381 | pos = daemon->connections; | 389 | pos = daemon->connections; |
382 | while (pos != NULL) { | 390 | while (pos != NULL) { |
383 | if (FD_ISSET(pos->socket_fd, &rs)) | 391 | ds = pos->socket_fd; |
392 | if (ds == -1) | ||
393 | continue; | ||
394 | if (FD_ISSET(ds, &rs)) | ||
384 | MHD_session_handle_read(pos); | 395 | MHD_session_handle_read(pos); |
385 | if (FD_ISSET(pos->socket_fd, &ws)) | 396 | if (FD_ISSET(ds, &ws)) |
386 | MHD_session_handle_write(pos); | 397 | MHD_session_handle_write(pos); |
387 | pos = pos->next; | 398 | pos = pos->next; |
388 | } | 399 | } |
@@ -542,9 +553,6 @@ MHD_stop_daemon(struct MHD_Daemon * daemon) { | |||
542 | close(daemon->connections->socket_fd); | 553 | close(daemon->connections->socket_fd); |
543 | daemon->connections->socket_fd = -1; | 554 | daemon->connections->socket_fd = -1; |
544 | } | 555 | } |
545 | if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) | ||
546 | pthread_join(daemon->connections->pid, &unused); | ||
547 | |||
548 | MHD_cleanup_sessions(daemon); | 556 | MHD_cleanup_sessions(daemon); |
549 | } | 557 | } |
550 | free(daemon); | 558 | 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() { | |||
131 | return 2; | 131 | return 2; |
132 | } | 132 | } |
133 | curl_easy_cleanup(c); | 133 | curl_easy_cleanup(c); |
134 | if (cbc.pos != strlen("hello_world")) { | 134 | if (cbc.pos != strlen("/hello_world")) { |
135 | MHD_stop_daemon(d); | 135 | MHD_stop_daemon(d); |
136 | return 4; | 136 | return 4; |
137 | } | 137 | } |
138 | 138 | ||
139 | if (0 != strncmp("hello_world", | 139 | if (0 != strncmp("/hello_world", |
140 | cbc.buf, | 140 | cbc.buf, |
141 | strlen("hello_world"))) { | 141 | strlen("/hello_world"))) { |
142 | MHD_stop_daemon(d); | 142 | MHD_stop_daemon(d); |
143 | return 8; | 143 | return 8; |
144 | } | 144 | } |
@@ -190,16 +190,18 @@ static int testMultithreadedGet() { | |||
190 | curl_easy_setopt(c, | 190 | curl_easy_setopt(c, |
191 | CURLOPT_NOSIGNAL, | 191 | CURLOPT_NOSIGNAL, |
192 | 1); | 192 | 1); |
193 | if (CURLE_OK != curl_easy_perform(c)) | 193 | if (CURLE_OK != curl_easy_perform(c)) { |
194 | MHD_stop_daemon(d); | ||
194 | return 32; | 195 | return 32; |
196 | } | ||
195 | curl_easy_cleanup(c); | 197 | curl_easy_cleanup(c); |
196 | if (cbc.pos != strlen("hello_world")) { | 198 | if (cbc.pos != strlen("/hello_world")) { |
197 | MHD_stop_daemon(d); | 199 | MHD_stop_daemon(d); |
198 | return 64; | 200 | return 64; |
199 | } | 201 | } |
200 | if (0 != strncmp("hello_world", | 202 | if (0 != strncmp("/hello_world", |
201 | cbc.buf, | 203 | cbc.buf, |
202 | strlen("hello_world"))) { | 204 | strlen("/hello_world"))) { |
203 | MHD_stop_daemon(d); | 205 | MHD_stop_daemon(d); |
204 | return 128; | 206 | return 128; |
205 | } | 207 | } |
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) { | |||
250 | } | 250 | } |
251 | pthread_mutex_unlock(&response->mutex); | 251 | pthread_mutex_unlock(&response->mutex); |
252 | pthread_mutex_destroy(&response->mutex); | 252 | pthread_mutex_destroy(&response->mutex); |
253 | if (response->crfc != NULL) | ||
254 | response->crfc(response->crc_cls); | ||
253 | while (response->first_header != NULL) { | 255 | while (response->first_header != NULL) { |
254 | pos = response->first_header; | 256 | pos = response->first_header; |
255 | response->first_header = pos->next; | 257 | 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) { | |||
275 | session->headers_received = hdr; | 275 | session->headers_received = hdr; |
276 | } | 276 | } |
277 | /* FIXME: here: find cookie header and parse that! */ | 277 | /* FIXME: here: find cookie header and parse that! */ |
278 | if (session->bodyReceived == 0) | ||
279 | return; | ||
280 | return; | 278 | return; |
281 | DIE: | 279 | DIE: |
282 | close(session->socket_fd); | 280 | close(session->socket_fd); |