From: Brian Pane Date: Mon, 1 Jul 2002 05:05:51 +0000 (+0000) Subject: Optimization for ap_rgetline_core(): When "folding" mode is enabled, X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=32e6ad8d8392e495c209e4821eabf7abc10b3694;p=apache Optimization for ap_rgetline_core(): When "folding" mode is enabled, clear and re-use the temporary brigade rather than destroying it and creating a new one git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95920 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/protocol.c b/server/protocol.c index ed7b197265..59119846e3 100644 --- a/server/protocol.c +++ b/server/protocol.c @@ -335,9 +335,6 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n, bytes_handled += len; } - /* We no longer need the returned brigade. */ - apr_brigade_destroy(b); - /* We likely aborted early before reading anything or we read no * data. Technically, this might be success condition. But, * probably means something is horribly wrong. For now, we'll @@ -345,6 +342,7 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n, */ if (bytes_handled == 0) { *read = 0; + apr_brigade_destroy(b); return APR_SUCCESS; } @@ -370,6 +368,7 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n, rv = ap_rgetline_core(&tmp, next_size, &next_len, r, fold); if (rv != APR_SUCCESS) { + apr_brigade_destroy(b); return rv; } @@ -398,6 +397,7 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n, last_char = *s + bytes_handled - 1; } else { + apr_brigade_destroy(b); return APR_ENOSPC; } } @@ -438,41 +438,40 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n, */ if (fold && bytes_handled && !saw_eos) { const char *str; - apr_bucket_brigade *bb; apr_size_t len; char c; - /* Create a brigade for this filter read. */ - bb = apr_brigade_create(r->pool, r->connection->bucket_alloc); + /* Clear the temp brigade for this filter read. */ + apr_brigade_cleanup(b); /* We only care about the first byte. */ - rv = ap_get_brigade(r->input_filters, bb, AP_MODE_SPECULATIVE, + rv = ap_get_brigade(r->input_filters, b, AP_MODE_SPECULATIVE, APR_BLOCK_READ, 1); if (rv != APR_SUCCESS) { - apr_brigade_destroy(bb); + apr_brigade_destroy(b); return rv; } - if (APR_BRIGADE_EMPTY(bb)) { + if (APR_BRIGADE_EMPTY(b)) { *read = bytes_handled; - apr_brigade_destroy(bb); + apr_brigade_destroy(b); return APR_SUCCESS; } - e = APR_BRIGADE_FIRST(bb); + e = APR_BRIGADE_FIRST(b); /* If we see an EOS, don't bother doing anything more. */ if (APR_BUCKET_IS_EOS(e)) { *read = bytes_handled; - apr_brigade_destroy(bb); + apr_brigade_destroy(b); return APR_SUCCESS; } rv = apr_bucket_read(e, &str, &len, APR_BLOCK_READ); if (rv != APR_SUCCESS) { - apr_brigade_destroy(bb); + apr_brigade_destroy(b); return rv; } @@ -482,9 +481,6 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n, */ c = *str; - /* We no longer need the returned brigade. */ - apr_brigade_destroy(bb); - /* Found one, so call ourselves again to get the next line. * * FIXME: If the folding line is completely blank, should we @@ -512,6 +508,7 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n, rv = ap_rgetline_core(&tmp, next_size, &next_len, r, fold); if (rv != APR_SUCCESS) { + apr_brigade_destroy(b); return rv; } @@ -531,15 +528,18 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n, } *read = bytes_handled + next_len; + apr_brigade_destroy(b); return APR_SUCCESS; } else { + apr_brigade_destroy(b); return APR_ENOSPC; } } } *read = bytes_handled; + apr_brigade_destroy(b); return APR_SUCCESS; }