From: Yann Ylavic Date: Thu, 27 Jan 2022 15:06:55 +0000 (+0000) Subject: mpm_event: Use APR_POLLEXCL when available to prevent thundering hurd. X-Git-Tag: 2.5.0-alpha2-ci-test-only~534 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4afce44d844474ee7190c1c5e0eadb0d91483dcf;p=thirdparty%2Fapache%2Fhttpd.git 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 --- diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index 8fda4bee7b3..aab61ac11db 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;