]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mpm_event: Use APR_POLLEXCL when available to prevent thundering hurd.
authorYann Ylavic <ylavic@apache.org>
Thu, 27 Jan 2022 15:06:55 +0000 (15:06 +0000)
committerYann Ylavic <ylavic@apache.org>
Thu, 27 Jan 2022 15:06:55 +0000 (15:06 +0000)
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

server/mpm/event/event.c

index 8fda4bee7b361a01ef1fc02dc13d75413f9beb57..aab61ac11db0ba3c51a7cb3c1bfc0e7277c075bd 100644 (file)
@@ -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;