]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Backport to v2.4:
authorGraham Leggett <minfrin@apache.org>
Mon, 17 Jul 2023 20:36:38 +0000 (20:36 +0000)
committerGraham Leggett <minfrin@apache.org>
Mon, 17 Jul 2023 20:36:38 +0000 (20:36 +0000)
  *) core: Optimize send_brigade_nonblocking()
     trunk patch:
        https://svn.apache.org/r1892450
        https://svn.apache.org/r1909966
     2.4.x patch: svn merge -c 1892450,1909966 ^/httpd/httpd/trunk .
     +1: jailletc36, rpluem, icing

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1911074 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
server/core_filters.c

diff --git a/CHANGES b/CHANGES
index 86c6046714472c34f677f0c9343fa20f200f8606..90a77313ac8c793e7ba2c2c0c3f156b75ee1c135 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.4.58
 
+  *) core: Optimize send_brigade_nonblocking(). [Christophe Jaillet]
+
   *) Easy patches: synch 2.4.x and trunk
          - core: constify pointers in ap_expr lookup tables.
                  ~1/2Kb moves to r/o text section
diff --git a/STATUS b/STATUS
index 1fe1f78951cd31684aab752a134f3a2f5c737d22..dcf9f9068128ae1b9ef48ec7e9c957eb95687075 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -152,13 +152,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  *) core: Optimize send_brigade_nonblocking()
-     trunk patch:
-        https://svn.apache.org/r1892450
-        https://svn.apache.org/r1909966
-     2.4.x patch: svn merge -c 1892450,1909966 ^/httpd/httpd/trunk .
-     +1: jailletc36, rpluem, icing
-
   *) mod_deflate: Add DeflateAlterETag to control how the ETag
      is modified. The 'NoChange' parameter mimics 2.2.x behavior.
      PR 45023, PR 39727.
index d8a661f8cc25b2e737c3a9fd4a37f3785e7b401e..c4ab6030bdce93baf438e789900ba7975dd7514f 100644 (file)
@@ -719,41 +719,41 @@ static apr_status_t send_brigade_nonblocking(apr_socket_t *s,
             if (!nvec) {
                 apr_bucket_delete(bucket);
             }
-            continue;
         }
-
-        /* Make sure that these new data fit in our iovec. */
-        if (nvec == ctx->nvec) {
-            if (nvec == NVEC_MAX) {
-                sock_nopush(s, 1);
-                rv = writev_nonblocking(s, bb, ctx, nbytes, nvec, c);
-                if (rv != APR_SUCCESS) {
-                    goto cleanup;
-                }
-                nbytes = 0;
-                nvec = 0;
-            }
-            else {
-                struct iovec *newvec;
-                apr_size_t newn = nvec * 2;
-                if (newn < NVEC_MIN) {
-                    newn = NVEC_MIN;
-                }
-                else if (newn > NVEC_MAX) {
-                    newn = NVEC_MAX;
+        else {
+            /* Make sure that these new data fit in our iovec. */
+            if (nvec == ctx->nvec) {
+                if (nvec == NVEC_MAX) {
+                    sock_nopush(s, 1);
+                    rv = writev_nonblocking(s, bb, ctx, nbytes, nvec, c);
+                    if (rv != APR_SUCCESS) {
+                        goto cleanup;
+                    }
+                    nbytes = 0;
+                    nvec = 0;
                 }
-                newvec = apr_palloc(c->pool, newn * sizeof(struct iovec));
-                if (nvec) {
-                    memcpy(newvec, ctx->vec, nvec * sizeof(struct iovec));
+                else {
+                    struct iovec *newvec;
+                    apr_size_t newn = nvec * 2;
+                    if (newn < NVEC_MIN) {
+                        newn = NVEC_MIN;
+                    }
+                    else if (newn > NVEC_MAX) {
+                        newn = NVEC_MAX;
+                    }
+                    newvec = apr_palloc(c->pool, newn * sizeof(struct iovec));
+                    if (nvec) {
+                        memcpy(newvec, ctx->vec, nvec * sizeof(struct iovec));
+                    }
+                    ctx->vec = newvec;
+                    ctx->nvec = newn;
                 }
-                ctx->vec = newvec;
-                ctx->nvec = newn;
             }
+            nbytes += length;
+            ctx->vec[nvec].iov_base = (void *)data;
+            ctx->vec[nvec].iov_len = length;
+            nvec++;
         }
-        nbytes += length;
-        ctx->vec[nvec].iov_base = (void *)data;
-        ctx->vec[nvec].iov_len = length;
-        nvec++;
 
         /* Flush above max threshold, unless the brigade still contains in
          * memory buckets which we want to try writing in the same pass (if
@@ -762,7 +762,7 @@ static apr_status_t send_brigade_nonblocking(apr_socket_t *s,
          */
         if (nbytes > conf->flush_max_threshold
                 && next != APR_BRIGADE_SENTINEL(bb)
-                && !is_in_memory_bucket(next)) {
+                && next->length && !is_in_memory_bucket(next)) {
             sock_nopush(s, 1);
             rv = writev_nonblocking(s, bb, ctx, nbytes, nvec, c);
             if (rv != APR_SUCCESS) {