]> granicus.if.org Git - apache/commitdiff
Use APR_POLLSET_NOCOPY for better performance with some pollset implementations.
authorJeff Trawick <trawick@apache.org>
Wed, 4 Mar 2009 19:13:07 +0000 (19:13 +0000)
committerJeff Trawick <trawick@apache.org>
Wed, 4 Mar 2009 19:13:07 +0000 (19:13 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@750108 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
support/ab.c

diff --git a/CHANGES b/CHANGES
index c73824dec0c3903c6d6174e71be00769f629b683..cb9028c29cdd3b0a9ed1becddd8d948134fed355 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,7 +6,8 @@ Changes with Apache 2.3.2
 
   *) ab: Fix maintenance of the pollset to resolve EALREADY errors 
      with kqueue (BSD/OS X) and excessive CPU with event ports (Solaris).
-     PR 44584.  [Jeff Trawick]
+     PR 44584.  Use APR_POLLSET_NOCOPY for better performance with some
+     pollset implementations.  [Jeff Trawick]
 
   *) mod_disk_cache: The module now turns off sendfile support if
      'EnableSendfile off' is defined globally. [Lars Eilebrecht]
index 30a280a2fe3169caca6285c30922b6bd54c5cc24..58b67a9658dadb92497d2257211d7d456df9b4de 100644 (file)
@@ -226,6 +226,7 @@ typedef enum {
 struct connection {
     apr_pool_t *ctx;
     apr_socket_t *aprsock;
+    apr_pollfd_t pollfd;
     int state;
     apr_size_t read;            /* amount of bytes read */
     apr_size_t bread;           /* amount of body read */
@@ -244,7 +245,6 @@ struct connection {
                done;            /* Connection closed */
 
     int socknum;
-    apr_int16_t reqevents;      /* current poll events for this socket */
 #ifdef USE_SSL
     SSL *ssl;
 #endif
@@ -391,32 +391,23 @@ static void apr_err(char *s, apr_status_t rv)
 
 static void set_polled_events(struct connection *c, apr_int16_t new_reqevents)
 {
-    apr_int16_t old_reqevents = c->reqevents;
-    apr_pollfd_t pfd;
     apr_status_t rv;
 
-    if (old_reqevents != new_reqevents) {
-        pfd.desc_type = APR_POLL_SOCKET;
-        pfd.desc.s = c->aprsock;
-        pfd.client_data = c;
-
-        if (old_reqevents != 0) {
-            pfd.reqevents = old_reqevents;
-            rv = apr_pollset_remove(readbits, &pfd);
+    if (c->pollfd.reqevents != new_reqevents) {
+        if (c->pollfd.reqevents != 0) {
+            rv = apr_pollset_remove(readbits, &c->pollfd);
             if (rv != APR_SUCCESS) {
                 apr_err("apr_pollset_remove()", rv);
             }
         }
 
         if (new_reqevents != 0) {
-            pfd.reqevents = new_reqevents;
-            rv = apr_pollset_add(readbits, &pfd);
+            c->pollfd.reqevents = new_reqevents;
+            rv = apr_pollset_add(readbits, &c->pollfd);
             if (rv != APR_SUCCESS) {
                 apr_err("apr_pollset_add()", rv);
             }
         }
-
-        c->reqevents = new_reqevents;
     }
 }
 
@@ -1188,6 +1179,12 @@ static void start_connect(struct connection * c)
                 SOCK_STREAM, 0, c->ctx)) != APR_SUCCESS) {
     apr_err("socket", rv);
     }
+
+    c->pollfd.desc_type = APR_POLL_SOCKET;
+    c->pollfd.desc.s = c->aprsock;
+    c->pollfd.reqevents = 0;
+    c->pollfd.client_data = c;
+
     if ((rv = apr_socket_opt_set(c->aprsock, APR_SO_NONBLOCK, 1))
          != APR_SUCCESS) {
         apr_err("socket nonblock", rv);
@@ -1581,7 +1578,8 @@ static void test(void)
 
     stats = calloc(requests, sizeof(struct data));
 
-    if ((status = apr_pollset_create(&readbits, concurrency, cntxt, 0)) != APR_SUCCESS) {
+    if ((status = apr_pollset_create(&readbits, concurrency, cntxt,
+                                     APR_POLLSET_NOCOPY)) != APR_SUCCESS) {
         apr_err("apr_pollset_create failed", status);
     }