]> granicus.if.org Git - apache/commitdiff
Morph the ap_http_broken_backend_filter() proxy "specific"
authorJim Jagielski <jim@apache.org>
Tue, 20 Dec 2005 15:50:37 +0000 (15:50 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 20 Dec 2005 15:50:37 +0000 (15:50 +0000)
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

modules/http/http_core.c
modules/http/http_filters.c
modules/http/mod_core.h
modules/proxy/mod_proxy_http.c

index b939967e6e9f82f33c0c7ce94c9b43d5ee25ed39..a2a9aa41305ba588fcdcfc1c190890b58d313da0 100644 (file)
@@ -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,
index 9434ac1668e9191a9195737b8a9b80f7e0ffb77f..a9dfade6b97e349e9f08b96981570d9666921a60 100644 (file)
@@ -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;
+            }
         }
     }
 
index c084a755ec7de05562295b9cfd0b077ca91aeb9a..1cc7a67d3933b36a65c828ee5a746e3b80a9c5e8 100644 (file)
@@ -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);
 
index 83e40432a40a80825c464a953a6af11d9c6efbeb..31b892cbd59e53a1bf677f8ca462135dcf21e07b 100644 (file)
@@ -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");