From 4c780352f30e996760123508bb54f16a85f1ccbf Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Thu, 15 Nov 2012 16:49:04 +0000 Subject: [PATCH] Prefer higher-mode polling, but allow for drop down to default git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1409878 13f79535-47bb-0310-9956-ffa450edef68 --- server/mpm/event/event.c | 23 ++++++++++++++++++++--- server/mpm/eventopt/eventopt.c | 22 ++++++++++++++++++++-- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index 2945652311..23aa95d8f7 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -1951,6 +1951,7 @@ static void *APR_THREAD_FUNC start_threads(apr_thread_t * thd, void *dummy) int loops; int prev_threads_created; int max_recycled_pools = -1; + int good_methods[] = {APR_POLLSET_KQUEUE, APR_POLLSET_PORT, APR_POLLSET_EPOLL}; /* We must create the fd queues before we start up the listener * and worker threads. */ @@ -1989,18 +1990,34 @@ static void *APR_THREAD_FUNC start_threads(apr_thread_t * thd, void *dummy) } /* Create the main pollset */ - rv = apr_pollset_create(&event_pollset, - threads_per_child, /* XXX don't we need more, to handle + for (i = 0; i < sizeof(good_methods) / sizeof(void*); i++) { + rv = apr_pollset_create_ex(&event_pollset, + threads_per_child*2, /* XXX don't we need more, to handle * connections in K-A or lingering * close? */ - pchild, APR_POLLSET_THREADSAFE | APR_POLLSET_NOCOPY); + pchild, APR_POLLSET_THREADSAFE | APR_POLLSET_NOCOPY | APR_POLLSET_NODEFAULT, + good_methods[i]); + if (rv == APR_SUCCESS) { + break; + } + } + if (rv != APR_SUCCESS) { + rv = apr_pollset_create(&event_pollset, + threads_per_child*2, /* XXX don't we need more, to handle + * connections in K-A or lingering + * close? + */ + pchild, APR_POLLSET_THREADSAFE | APR_POLLSET_NOCOPY); + } if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, "apr_pollset_create with Thread Safety failed."); clean_child_exit(APEXIT_CHILDFATAL); } + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO() + "start_threads: Using %s", apr_pollset_method_name(event_pollset)); worker_sockets = apr_pcalloc(pchild, threads_per_child * sizeof(apr_socket_t *)); diff --git a/server/mpm/eventopt/eventopt.c b/server/mpm/eventopt/eventopt.c index ec9dfeffe5..a36414ad8f 100644 --- a/server/mpm/eventopt/eventopt.c +++ b/server/mpm/eventopt/eventopt.c @@ -1940,6 +1940,7 @@ static void *APR_THREAD_FUNC start_threads(apr_thread_t * thd, void *dummy) int loops; int prev_threads_created; int max_recycled_pools = -1; + int good_methods[] = {APR_POLLSET_KQUEUE, APR_POLLSET_PORT, APR_POLLSET_EPOLL}; /* We must create the fd queues before we start up the listener * and worker threads. */ @@ -1967,18 +1968,35 @@ static void *APR_THREAD_FUNC start_threads(apr_thread_t * thd, void *dummy) } /* Create the main pollset */ - rv = apr_pollset_create(&event_pollset, - threads_per_child, /* XXX don't we need more, to handle + for (i = 0; i < sizeof(good_methods) / sizeof(void*); i++) { + rv = apr_pollset_create_ex(&event_pollset, + threads_per_child*2, /* XXX don't we need more, to handle + * connections in K-A or lingering + * close? + */ + pchild, APR_POLLSET_WAKEABLE|APR_POLLSET_NOCOPY|APR_POLLSET_NODEFAULT, + good_methods[i]); + if (rv == APR_SUCCESS) { + break; + } + } + if (rv != APR_SUCCESS) { + rv = apr_pollset_create(&event_pollset, + threads_per_child*2, /* XXX don't we need more, to handle * connections in K-A or lingering * close? */ pchild, APR_POLLSET_WAKEABLE|APR_POLLSET_NOCOPY); + } if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, "apr_pollset_create failed; check system or user limits"); clean_child_exit(APEXIT_CHILDFATAL); } + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO() + "start_threads: Using %s", apr_pollset_method_name(event_pollset)); + worker_sockets = apr_pcalloc(pchild, threads_per_child * sizeof(apr_socket_t *)); -- 2.40.0