From: Graham Leggett Date: Mon, 17 Jul 2023 20:36:38 +0000 (+0000) Subject: Backport to v2.4: X-Git-Tag: 2.4.58-rc1-candidate~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d8bf133d821035a046f1bd59c3b9a9eef7df738;p=thirdparty%2Fapache%2Fhttpd.git Backport to v2.4: *) 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 --- diff --git a/CHANGES b/CHANGES index 86c60467144..90a77313ac8 100644 --- 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 1fe1f78951c..dcf9f906812 100644 --- 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. diff --git a/server/core_filters.c b/server/core_filters.c index d8a661f8cc2..c4ab6030bdc 100644 --- a/server/core_filters.c +++ b/server/core_filters.c @@ -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) {