summaryrefslogtreecommitdiffstats
path: root/server/protocol.c
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2022-03-07 14:19:37 +0100
committerYann Ylavic <ylavic@apache.org>2022-03-07 14:19:37 +0100
commit0cb63842869cc2d9c02aba63c2122c685ac88d76 (patch)
tree23c3a4c3ea9de72fc8d240360bb23aaafad2ba63 /server/protocol.c
parentAdjust Travis branch-matching conditions to treat any (diff)
downloadapache2-0cb63842869cc2d9c02aba63c2122c685ac88d76.tar.xz
apache2-0cb63842869cc2d9c02aba63c2122c685ac88d76.zip
core: Simpler connection close logic if discarding the request body fails.
If ap_discard_request_body() sets AP_CONN_CLOSE by itself it simplifies and allows to consolidate end_output_stream() and error_output_stream(). git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1898683 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--server/protocol.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/server/protocol.c b/server/protocol.c
index 0c3b770ad5..c5570f6d5b 100644
--- a/server/protocol.c
+++ b/server/protocol.c
@@ -1734,38 +1734,29 @@ AP_DECLARE(void) ap_set_sub_req_protocol(request_rec *rnew,
rnew->main = (request_rec *) r;
}
-static void error_output_stream(request_rec *r, int status)
+static void end_output_stream(request_rec *r, int status)
{
conn_rec *c = r->connection;
apr_bucket_brigade *bb;
apr_bucket *b;
bb = apr_brigade_create(r->pool, c->bucket_alloc);
- b = ap_bucket_error_create(status, NULL, r->pool,
- r->connection->bucket_alloc);
- APR_BRIGADE_INSERT_TAIL(bb, b);
+ if (status != OK) {
+ b = ap_bucket_error_create(status, NULL, r->pool, c->bucket_alloc);
+ APR_BRIGADE_INSERT_TAIL(bb, b);
+ }
b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
- ap_pass_brigade(r->output_filters, bb);
-}
-static void end_output_stream(request_rec *r)
-{
- conn_rec *c = r->connection;
- apr_bucket_brigade *bb;
- apr_bucket *b;
-
- bb = apr_brigade_create(r->pool, c->bucket_alloc);
- b = apr_bucket_eos_create(c->bucket_alloc);
- APR_BRIGADE_INSERT_TAIL(bb, b);
ap_pass_brigade(r->output_filters, bb);
+ apr_brigade_cleanup(bb);
}
AP_DECLARE(void) ap_finalize_sub_req_protocol(request_rec *sub)
{
/* tell the filter chain there is no more content coming */
if (!sub->eos_sent) {
- end_output_stream(sub);
+ end_output_stream(sub, OK);
}
}
@@ -1779,11 +1770,8 @@ AP_DECLARE(void) ap_finalize_request_protocol(request_rec *r)
int status = ap_discard_request_body(r);
/* tell the filter chain there is no more content coming */
- if (status) {
- error_output_stream(r, status);
- }
if (!r->eos_sent) {
- end_output_stream(r);
+ end_output_stream(r, status);
}
}