]> granicus.if.org Git - apache/commitdiff
mpm_{worker,prefork}: save some cycles by not copying the listener's pollfds
authorYann Ylavic <ylavic@apache.org>
Thu, 26 Feb 2015 12:54:23 +0000 (12:54 +0000)
committerYann Ylavic <ylavic@apache.org>
Thu, 26 Feb 2015 12:54:23 +0000 (12:54 +0000)
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
server/mpm/worker/worker.c

index 56b2772e52a0038fbc13e710692ab4c4abbcfe0d..507a5a2295aceb6da9f2fe44800f29af52e33dc1 100644 (file)
@@ -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,
index d5fcc77cb5ed5c5e7422f6aff6f584c13fef3609..695024fc61df4e1bdbb5f547e89cb1d1956ec973 100644 (file)
@@ -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;"