From: Jim Jagielski Date: Tue, 20 Dec 2005 15:50:37 +0000 (+0000) Subject: Morph the ap_http_broken_backend_filter() proxy "specific" X-Git-Tag: 2.3.0~2646 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4f879aefa6636f1289b62db6068ee8289dcd8cb;p=thirdparty%2Fapache%2Fhttpd.git Morph the ap_http_broken_backend_filter() proxy "specific" filter to a generic http error handling output filter. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@358022 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http/http_core.c b/modules/http/http_core.c index b939967e6e9..a2a9aa41305 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -39,7 +39,7 @@ AP_DECLARE_DATA ap_filter_rec_t *ap_http_input_filter_handle; AP_DECLARE_DATA ap_filter_rec_t *ap_http_header_filter_handle; AP_DECLARE_DATA ap_filter_rec_t *ap_chunk_filter_handle; -AP_DECLARE_DATA ap_filter_rec_t *ap_broken_backend_filter_handle; +AP_DECLARE_DATA ap_filter_rec_t *ap_http_outerror_filter_handle; AP_DECLARE_DATA ap_filter_rec_t *ap_byterange_filter_handle; static const char *set_keep_alive_timeout(cmd_parms *cmd, void *dummy, @@ -208,6 +208,8 @@ static int http_create_request(request_rec *r) NULL, r, r->connection); ap_add_output_filter_handle(ap_http_header_filter_handle, NULL, r, r->connection); + ap_add_output_filter_handle(ap_http_outerror_filter_handle, + NULL, r, r->connection); } return OK; @@ -243,9 +245,8 @@ static void register_hooks(apr_pool_t *p) ap_chunk_filter_handle = ap_register_output_filter("CHUNK", ap_http_chunk_filter, NULL, AP_FTYPE_TRANSCODE); - ap_broken_backend_filter_handle = - ap_register_output_filter("BROKEN_BACKEND", - ap_http_broken_backend_filter, + ap_http_outerror_filter_handle = + ap_register_output_filter("HTTP_OUTERROR", ap_http_outerror_filter, NULL, AP_FTYPE_PROTOCOL); ap_byterange_filter_handle = ap_register_output_filter("BYTERANGE", ap_byterange_filter, diff --git a/modules/http/http_filters.c b/modules/http/http_filters.c index 9434ac1668e..a9dfade6b97 100644 --- a/modules/http/http_filters.c +++ b/modules/http/http_filters.c @@ -1055,9 +1055,6 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, */ ap_add_output_filter("CHUNK", NULL, r, r->connection); } - /* If we have a Proxy request, add the BROKEN_BACKEND filter now */ - if (r->proxyreq != PROXYREQ_NONE) - ap_add_output_filter("BROKEN_BACKEND", NULL, r, r->connection); /* Don't remove this filter until after we have added the CHUNK filter. * Otherwise, f->next won't be the CHUNK filter and thus the first @@ -1333,8 +1330,9 @@ AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, return bufsiz; } -apr_status_t ap_http_broken_backend_filter(ap_filter_t *f, - apr_bucket_brigade *b) +/* Filter to handle any error buckets on output */ +apr_status_t ap_http_outerror_filter(ap_filter_t *f, + apr_bucket_brigade *b) { request_rec *r = f->r; apr_bucket *e; @@ -1343,10 +1341,15 @@ apr_status_t ap_http_broken_backend_filter(ap_filter_t *f, e != APR_BRIGADE_SENTINEL(b); e = APR_BUCKET_NEXT(e)) { - if (AP_BUCKET_IS_ERROR(e) - && (((ap_bucket_error *)(e->data))->status == HTTP_BAD_GATEWAY)) { - /* stream aborted and we have not ended it yet */ - r->connection->keepalive = AP_CONN_CLOSE; + if (AP_BUCKET_IS_ERROR(e)) { + /* + * Start of error handling state tree. Just one condition + * right now :) + */ + if (((ap_bucket_error *)(e->data))->status == HTTP_BAD_GATEWAY) { + /* stream aborted and we have not ended it yet */ + r->connection->keepalive = AP_CONN_CLOSE; + } } } diff --git a/modules/http/mod_core.h b/modules/http/mod_core.h index c084a755ec7..1cc7a67d393 100644 --- a/modules/http/mod_core.h +++ b/modules/http/mod_core.h @@ -42,7 +42,7 @@ extern "C" { extern AP_DECLARE_DATA ap_filter_rec_t *ap_http_input_filter_handle; extern AP_DECLARE_DATA ap_filter_rec_t *ap_http_header_filter_handle; extern AP_DECLARE_DATA ap_filter_rec_t *ap_chunk_filter_handle; -extern AP_DECLARE_DATA ap_filter_rec_t *ap_broken_backend_filter_handle; +extern AP_DECLARE_DATA ap_filter_rec_t *ap_http_outerror_filter_handle; extern AP_DECLARE_DATA ap_filter_rec_t *ap_byterange_filter_handle; /* @@ -55,9 +55,9 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, /* HTTP/1.1 chunked transfer encoding filter. */ apr_status_t ap_http_chunk_filter(ap_filter_t *f, apr_bucket_brigade *b); -/* Filter to close the connection to the client if backend broke */ -apr_status_t ap_http_broken_backend_filter(ap_filter_t *f, - apr_bucket_brigade *b); +/* Filter to handle any error buckets on output */ +apr_status_t ap_http_outerror_filter(ap_filter_t *f, + apr_bucket_brigade *b); char *ap_response_code_string(request_rec *r, int error_index); diff --git a/modules/proxy/mod_proxy_http.c b/modules/proxy/mod_proxy_http.c index 83e40432a40..31b892cbd59 100644 --- a/modules/proxy/mod_proxy_http.c +++ b/modules/proxy/mod_proxy_http.c @@ -1481,7 +1481,8 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r, } else if (rv != APR_SUCCESS) { /* In this case, we are in real trouble because - * our backend bailed on us. + * our backend bailed on us. Pass along a 502 error + * error bucket */ ap_log_cerror(APLOG_MARK, APLOG_ERR, rv, c, "proxy: error reading response");