aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/daemon.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2007-06-13 21:57:36 +0000
committerChristian Grothoff <christian@grothoff.org>2007-06-13 21:57:36 +0000
commit817a963a53ce67d3efbcf223df0bbe35299dc38e (patch)
treee2d4dd680d13980efde175b50c81c354dfaf2c87 /src/daemon/daemon.c
parentb0912d1929accce21b75c97ab69c4c499ca9e921 (diff)
downloadlibmicrohttpd-817a963a53ce67d3efbcf223df0bbe35299dc38e.tar.gz
libmicrohttpd-817a963a53ce67d3efbcf223df0bbe35299dc38e.zip
essentials implemented
Diffstat (limited to 'src/daemon/daemon.c')
-rw-r--r--src/daemon/daemon.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index 2a2636db..490317ea 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -163,7 +163,8 @@ MHD_handle_connection(void * data) {
163 163
164 if (con == NULL) 164 if (con == NULL)
165 abort(); 165 abort();
166 while (! con->daemon->shutdown) { 166 while ( (! con->daemon->shutdown) &&
167 (con->socket_fd != -1) ) {
167 FD_ZERO(&rs); 168 FD_ZERO(&rs);
168 FD_ZERO(&ws); 169 FD_ZERO(&ws);
169 FD_ZERO(&es); 170 FD_ZERO(&es);
@@ -189,8 +190,10 @@ MHD_handle_connection(void * data) {
189 (MHD_YES != MHD_session_handle_write(con)) ) ) 190 (MHD_YES != MHD_session_handle_write(con)) ) )
190 break; 191 break;
191 } 192 }
192 close(con->socket_fd); 193 if (con->socket_fd != -1) {
193 con->socket_fd = -1; 194 close(con->socket_fd);
195 con->socket_fd = -1;
196 }
194 return NULL; 197 return NULL;
195} 198}
196 199
@@ -260,6 +263,11 @@ MHD_accept_connection(struct MHD_Daemon * daemon) {
260 * Free resources associated with all closed sessions. 263 * Free resources associated with all closed sessions.
261 * (destroy responses, free buffers, etc.). A session 264 * (destroy responses, free buffers, etc.). A session
262 * is known to be closed if the socket_fd is -1. 265 * is known to be closed if the socket_fd is -1.
266 *
267 * Also performs session actions that need to be run
268 * even if the session is not selectable (such as
269 * calling the application again with upload data when
270 * the upload data buffer is full).
263 */ 271 */
264static void 272static void
265MHD_cleanup_sessions(struct MHD_Daemon * daemon) { 273MHD_cleanup_sessions(struct MHD_Daemon * daemon) {
@@ -295,6 +303,13 @@ MHD_cleanup_sessions(struct MHD_Daemon * daemon) {
295 MHD_destroy_response(pos->response); 303 MHD_destroy_response(pos->response);
296 free(pos); 304 free(pos);
297 } 305 }
306
307 if ( (pos->headersReceived == 1) &&
308 (pos->read_buffer_size == pos->readLoc) &&
309 (pos->readLoc > 0) )
310 MHD_call_session_handler(pos);
311
312
298 prev = pos; 313 prev = pos;
299 pos = pos->next; 314 pos = pos->next;
300 } 315 }