You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by br...@apache.org on 2002/07/01 07:05:51 UTC
cvs commit: httpd-2.0/server protocol.c
brianp 2002/06/30 22:05:51
Modified: server protocol.c
Log:
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
Revision Changes Path
1.108 +16 -16 httpd-2.0/server/protocol.c
Index: protocol.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/protocol.c,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -r1.107 -r1.108
--- protocol.c 26 Jun 2002 19:45:07 -0000 1.107
+++ protocol.c 1 Jul 2002 05:05:51 -0000 1.108
@@ -335,9 +335,6 @@
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 @@
*/
if (bytes_handled == 0) {
*read = 0;
+ apr_brigade_destroy(b);
return APR_SUCCESS;
}
@@ -370,6 +368,7 @@
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 @@
last_char = *s + bytes_handled - 1;
}
else {
+ apr_brigade_destroy(b);
return APR_ENOSPC;
}
}
@@ -438,41 +438,40 @@
*/
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 @@
*/
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 @@
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 @@
}
*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;
}