commit 5c28c2ffcbd886b6dda0dae480cd459890f76cb1
parent 44a92f9f53feccebb45d5cfb3a3d73c1eecd80c8
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Sun, 4 Jun 2017 14:26:46 +0300
internal_add_connection(): improved thread safety in epoll mode with 'external' add
Diffstat:
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
@@ -2625,21 +2625,11 @@ internal_add_connection (struct MHD_Daemon *daemon,
goto cleanup;
}
}
- else
- if ( (external_add) &&
- (MHD_ITC_IS_VALID_(daemon->itc)) &&
- (! MHD_itc_activate_ (daemon->itc, "n")) )
- {
-#ifdef HAVE_MESSAGES
- MHD_DLOG (daemon,
- _("Failed to signal new connection via inter-thread communication channel."));
-#endif
- }
#ifdef EPOLL_SUPPORT
if (0 != (daemon->options & MHD_USE_EPOLL))
{
- if (0 == (daemon->options & MHD_USE_TURBO))
- {
+ if ((0 == (daemon->options & MHD_USE_TURBO)) || (external_add))
+ { /* Do not manipulate EReady DL-list in 'external_add' mode. */
struct epoll_event event;
event.events = EPOLLIN | EPOLLOUT | EPOLLPRI | EPOLLET;
@@ -2668,7 +2658,18 @@ internal_add_connection (struct MHD_Daemon *daemon,
connection);
}
}
+ else /* This 'else' is combined with next 'if'. */
#endif
+ if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
+ (external_add) &&
+ (MHD_ITC_IS_VALID_(daemon->itc)) &&
+ (! MHD_itc_activate_ (daemon->itc, "n")) )
+ {
+#ifdef HAVE_MESSAGES
+ MHD_DLOG (daemon,
+ _("Failed to signal new connection via inter-thread communication channel."));
+#endif
+ }
daemon->connections++;
return MHD_YES;
cleanup: