From 9aa869ec413b13c0c92d458fbe7369546367b3ce Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Thu, 26 Feb 2015 12:54:23 +0000 Subject: [PATCH] mpm_{worker,prefork}: save some cycles by not copying the listener's pollfds for each pollset operation. We don't need a copy when poll()ing if those are allocated with the correct lifetime (the listener thread) at the very beginning. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1662437 13f79535-47bb-0310-9956-ffa450edef68 --- server/mpm/prefork/prefork.c | 15 ++++++++------- server/mpm/worker/worker.c | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index 56b2772e52..507a5a2295 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -570,7 +570,8 @@ static void child_main(int child_num_arg, int child_bucket) (void) ap_update_child_status(sbh, SERVER_READY, (request_rec *) NULL); /* Set up the pollfd array */ - status = apr_pollset_create(&pollset, num_listensocks, pchild, 0); + status = apr_pollset_create(&pollset, num_listensocks, pchild, + APR_POLLSET_NOCOPY); if (status != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, status, ap_server_conf, APLOGNO(00156) "Couldn't create pollset in child; check system or user limits"); @@ -578,14 +579,14 @@ static void child_main(int child_num_arg, int child_bucket) } for (lr = my_bucket->listeners, i = num_listensocks; i--; lr = lr->next) { - apr_pollfd_t pfd = { 0 }; + apr_pollfd_t *pfd = apr_pcalloc(pchild, sizeof *pfd); - pfd.desc_type = APR_POLL_SOCKET; - pfd.desc.s = lr->sd; - pfd.reqevents = APR_POLLIN; - pfd.client_data = lr; + pfd->desc_type = APR_POLL_SOCKET; + pfd->desc.s = lr->sd; + pfd->reqevents = APR_POLLIN; + pfd->client_data = lr; - status = apr_pollset_add(pollset, &pfd); + status = apr_pollset_add(pollset, pfd); if (status != APR_SUCCESS) { /* If the child processed a SIGWINCH before setting up the * pollset, this error path is expected and harmless, diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c index d5fcc77cb5..695024fc61 100644 --- a/server/mpm/worker/worker.c +++ b/server/mpm/worker/worker.c @@ -705,7 +705,8 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t *thd, void * dummy) free(ti); - rv = apr_pollset_create(&pollset, num_listensocks, tpool, 0); + rv = apr_pollset_create(&pollset, num_listensocks, tpool, + APR_POLLSET_NOCOPY); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, "Couldn't create pollset in thread;" @@ -715,14 +716,14 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t *thd, void * dummy) } for (lr = my_bucket->listeners; lr != NULL; lr = lr->next) { - apr_pollfd_t pfd = { 0 }; + apr_pollfd_t *pfd = apr_pcalloc(tpool, sizeof *pfd); - pfd.desc_type = APR_POLL_SOCKET; - pfd.desc.s = lr->sd; - pfd.reqevents = APR_POLLIN; - pfd.client_data = lr; + pfd->desc_type = APR_POLL_SOCKET; + pfd->desc.s = lr->sd; + pfd->reqevents = APR_POLLIN; + pfd->client_data = lr; - rv = apr_pollset_add(pollset, &pfd); + rv = apr_pollset_add(pollset, pfd); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, "Couldn't create add listener to pollset;" -- 2.50.1