commit 634cb0abd867bee5668d4501a4b63b950e5b481c
parent 3e15e43b1fa979a53eab353fa95dc2ed10fcb17c
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Sun, 23 Oct 2016 19:43:17 +0300
Cleanup minor improvement: signal select()'s thread at right moment.
Diffstat:
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
@@ -523,19 +523,6 @@ MHD_connection_close_ (struct MHD_Connection *connection,
&connection->client_context,
termination_code);
connection->client_aware = MHD_NO;
-
- /* if we were at the connection limit before and are in
- thread-per-connection mode, signal the main thread
- to resume accepting connections */
- if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
- (MHD_ITC_IS_VALID_ (daemon->itc)) &&
- (! MHD_itc_activate_ (daemon->itc, "c")) )
- {
-#ifdef HAVE_MESSAGES
- MHD_DLOG (daemon,
- _("Failed to signal end of connection via inter-thread communication channel"));
-#endif
- }
}
@@ -2610,7 +2597,20 @@ cleanup_connection (struct MHD_Connection *connection)
connection->resuming = MHD_NO;
connection->in_idle = MHD_NO;
if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
- MHD_mutex_unlock_chk_(&daemon->cleanup_connection_mutex);
+ {
+ MHD_mutex_unlock_chk_(&daemon->cleanup_connection_mutex);
+ /* if we were at the connection limit before and are in
+ thread-per-connection mode, signal the main thread
+ to resume accepting connections */
+ if ( (MHD_ITC_IS_VALID_ (daemon->itc)) &&
+ (! MHD_itc_activate_ (daemon->itc, "c")) )
+ {
+#ifdef HAVE_MESSAGES
+ MHD_DLOG (daemon,
+ _("Failed to signal end of connection via inter-thread communication channel"));
+#endif
+ }
+ }
}