summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2022-01-27 15:06:55 +0000
committerYann Ylavic <ylavic@apache.org>2022-01-27 15:06:55 +0000
commit4afce44d844474ee7190c1c5e0eadb0d91483dcf (patch)
treed7266ad482df06413bca33e24569c1cd18b0cb5b
parent3e0035d1892b7e8506cc2f53921282aaab8e4c23 (diff)
downloadhttpd-4afce44d844474ee7190c1c5e0eadb0d91483dcf.tar.gz
mpm_event: Use APR_POLLEXCL when available to prevent thundering hurd.
If APR_POLLEXCL is available, use it to prevent the thundering herd issue. The listening sockets are potentially polled by all the children at the same time, when new connections arrive this avoids all of them to be woken up while most would get EAGAIN on accept(). git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897551 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--server/mpm/event/event.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c
index 8fda4bee7b..aab61ac11d 100644
--- a/server/mpm/event/event.c
+++ b/server/mpm/event/event.c
@@ -2699,6 +2699,15 @@ static void setup_threads_runtime(void)
pfd = &listener_pollfd[i];
pfd->reqevents = APR_POLLIN | APR_POLLHUP | APR_POLLERR;
+#ifdef APR_POLLEXCL
+ /* If APR_POLLEXCL is available, use it to prevent the thundering
+ * herd issue. The listening sockets are potentially polled by all
+ * the children at the same time, when new connections arrive this
+ * avoids all of them to be woken up while most would get EAGAIN
+ * on accept().
+ */
+ pfd->reqevents |= APR_POLLEXCL;
+#endif
pfd->desc_type = APR_POLL_SOCKET;
pfd->desc.s = lr->sd;