aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/daemon.c')
-rw-r--r--src/daemon/daemon.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index 385e37c3..79963d6b 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -41,6 +41,12 @@
41#define MHD_POOL_SIZE_DEFAULT (1024 * 1024) 41#define MHD_POOL_SIZE_DEFAULT (1024 * 1024)
42 42
43/** 43/**
44 * Print extra messages with reasons for closing
45 * sockets? (only adds non-error messages).
46 */
47#define DEBUG_CLOSE 0
48
49/**
44 * Register an access handler for all URIs beginning with uri_prefix. 50 * Register an access handler for all URIs beginning with uri_prefix.
45 * 51 *
46 * @param uri_prefix 52 * @param uri_prefix
@@ -218,6 +224,10 @@ MHD_handle_connection (void *data)
218 } 224 }
219 if (con->socket_fd != -1) 225 if (con->socket_fd != -1)
220 { 226 {
227#if DEBUG_CLOSE
228 MHD_DLOG (con->daemon,
229 "Processing thread terminating, closing connection\n");
230#endif
221 CLOSE (con->socket_fd); 231 CLOSE (con->socket_fd);
222 con->socket_fd = -1; 232 con->socket_fd = -1;
223 } 233 }
@@ -263,6 +273,10 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
263 if ((daemon->apc != NULL) && 273 if ((daemon->apc != NULL) &&
264 (MHD_NO == daemon->apc (daemon->apc_cls, addr, addrlen))) 274 (MHD_NO == daemon->apc (daemon->apc_cls, addr, addrlen)))
265 { 275 {
276#if DEBUG_CLOSE
277 MHD_DLOG (daemon,
278 "Connection rejected, closing connection\n");
279#endif
266 CLOSE (s); 280 CLOSE (s);
267 return MHD_YES; 281 return MHD_YES;
268 } 282 }
@@ -334,6 +348,10 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
334 { 348 {
335 if ((pos->last_activity < timeout) && (pos->socket_fd != -1)) 349 if ((pos->last_activity < timeout) && (pos->socket_fd != -1))
336 { 350 {
351#if DEBUG_CLOSE
352 MHD_DLOG (daemon,
353 "Connection timed out, closing connection\n");
354#endif
337 CLOSE (pos->socket_fd); 355 CLOSE (pos->socket_fd);
338 pos->socket_fd = -1; 356 pos->socket_fd = -1;
339 } 357 }
@@ -470,7 +488,7 @@ MHD_select (struct MHD_Daemon *daemon, int may_block)
470 /* ltimeout is in ms */ 488 /* ltimeout is in ms */
471 if (MHD_YES == MHD_get_timeout (daemon, &ltimeout)) 489 if (MHD_YES == MHD_get_timeout (daemon, &ltimeout))
472 { 490 {
473 timeout.tv_usec = (ltimeout % 1000) * 1000 * 1000; 491 timeout.tv_usec = (ltimeout % 1000) * 1000;
474 timeout.tv_sec = ltimeout / 1000; 492 timeout.tv_sec = ltimeout / 1000;
475 may_block = MHD_NO; 493 may_block = MHD_NO;
476 } 494 }
@@ -705,6 +723,10 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
705 daemon->shutdown = MHD_YES; 723 daemon->shutdown = MHD_YES;
706 fd = daemon->socket_fd; 724 fd = daemon->socket_fd;
707 daemon->socket_fd = -1; 725 daemon->socket_fd = -1;
726#if DEBUG_CLOSE
727 MHD_DLOG (daemon,
728 "MHD shutdown, closing listen socket\n");
729#endif
708 CLOSE (fd); 730 CLOSE (fd);
709 if ((0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || 731 if ((0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) ||
710 (0 != (daemon->options & MHD_USE_SELECT_INTERNALLY))) 732 (0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)))
@@ -716,6 +738,10 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
716 { 738 {
717 if (-1 != daemon->connections->socket_fd) 739 if (-1 != daemon->connections->socket_fd)
718 { 740 {
741#if DEBUG_CLOSE
742 MHD_DLOG (daemon,
743 "MHD shutdown, closing active connections\n");
744#endif
719 CLOSE (daemon->connections->socket_fd); 745 CLOSE (daemon->connections->socket_fd);
720 daemon->connections->socket_fd = -1; 746 daemon->connections->socket_fd = -1;
721 } 747 }