You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@apache.org on 2014/04/11 19:07:18 UTC

svn commit: r1586719 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h modules/proxy/mod_proxy.c modules/proxy/mod_proxy.h modules/proxy/mod_proxy_http.c

Author: trawick
Date: Fri Apr 11 17:07:18 2014
New Revision: 1586719

URL: http://svn.apache.org/r1586719
Log:
mod_proxy_http: Add detach_backend hook.

The immediate use is for a SSL-related module which works
on the backend proxy connection to be able to "leak" information
into the client r for logging.

This could be useful with other proxy scheme handlers.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/modules/proxy/mod_proxy.c
    httpd/httpd/trunk/modules/proxy/mod_proxy.h
    httpd/httpd/trunk/modules/proxy/mod_proxy_http.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1586719&r1=1586718&r2=1586719&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Fri Apr 11 17:07:18 2014
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) mod_proxy_http: Add detach_backend hook (potentially usable
+     in other proxy scheme handlers).  [Jeff Trawick]
+
   *) mod_deflate: Add DeflateAlterETag to control how the ETag
      is modified. The 'NoChange' parameter mimics 2.2.x behavior.
      PR 45023, PR 39727. [Eric Covener]

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1586719&r1=1586718&r2=1586719&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Fri Apr 11 17:07:18 2014
@@ -449,6 +449,7 @@
  * 20131230.2 (2.5.0-dev)  Prefix REWRITE_REDIRECT_HANDLER_NAME in mod_rewrite.h
  * 20140207.0 (2.5.0-dev)  Support for slaved connections in core.c
  * 20140207.1 (2.5.0-dev)  Add SSL reusable SNI to mod_proxy.h's proxy_conn_rec
+ * 20140207.2 (2.5.0-dev)  Add proxy detach_backend hook
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
@@ -456,7 +457,7 @@
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20140207
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 1                  /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 2                  /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.c?rev=1586719&r1=1586718&r2=1586719&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Fri Apr 11 17:07:18 2014
@@ -2779,3 +2779,7 @@ APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(prox
                                     (int *status, request_rec *r),
                                     (status, r),
                                     OK, DECLINED)
+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(proxy, PROXY, int, detach_backend,
+                                    (request_rec *r, proxy_conn_rec *backend),
+                                    (r, backend), OK, DECLINED)
+

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=1586719&r1=1586718&r2=1586719&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Fri Apr 11 17:07:18 2014
@@ -513,6 +513,15 @@ APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, 
 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, fixups, (request_rec *r))
 
 /**
+ * Let modules perform processing when the connection to the origin is being
+ * detached from the request.
+ * @param r The client request
+ * @param backend The proxy representation of the backend connection
+ */
+APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, detach_backend, (request_rec *r,
+                                                              proxy_conn_rec *backend))
+
+/**
  * pre request hook.
  * It will return the most suitable worker at the moment
  * and coresponding balancer.

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_http.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_http.c?rev=1586719&r1=1586718&r2=1586719&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_http.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_http.c Fri Apr 11 17:07:18 2014
@@ -1309,6 +1309,7 @@ int ap_proxy_http_process_response(apr_p
                 apr_table_setn(r->notes, "proxy_timedout", "1");
                 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01103) "read timeout");
                 if (do_100_continue) {
+                    proxy_run_detach_backend(r, backend);
                     return ap_proxyerror(r, HTTP_SERVICE_UNAVAILABLE, "Timeout on 100-Continue");
                 }
             }
@@ -1341,6 +1342,7 @@ int ap_proxy_http_process_response(apr_p
                 /* Mark the backend connection for closing */
                 backend->close = 1;
                 /* Need to return OK to avoid sending an error message */
+                proxy_run_detach_backend(r, backend);
                 return OK;
             }
             else if (!c->keepalives) {
@@ -1350,6 +1352,7 @@ int ap_proxy_http_process_response(apr_p
                                    " failed.",
                                    backend->hostname, backend->port);
             }
+            proxy_run_detach_backend(r, backend);
             return ap_proxyerror(r, HTTP_GATEWAY_TIME_OUT,
                                  "Error reading from remote server");
         }
@@ -1369,6 +1372,7 @@ int ap_proxy_http_process_response(apr_p
              * if the status line was > 8192 bytes
              */
             if ((major != 1) || (len >= sizeof(buffer)-1)) {
+                proxy_run_detach_backend(r, backend);
                 return ap_proxyerror(r, HTTP_BAD_GATEWAY,
                 apr_pstrcat(p, "Corrupt status line returned by remote "
                             "server: ", buffer, NULL));
@@ -1427,6 +1431,7 @@ int ap_proxy_http_process_response(apr_p
                 r->headers_out = apr_table_make(r->pool,1);
                 r->status = HTTP_BAD_GATEWAY;
                 r->status_line = "bad gateway";
+                proxy_run_detach_backend(r, backend);
                 return r->status;
             }
 
@@ -1624,6 +1629,7 @@ int ap_proxy_http_process_response(apr_p
                 (proxy_status != HTTP_NOT_MODIFIED)) { /* not 304 */
                 ap_discard_request_body(backend->r);
             }
+            proxy_run_detach_backend(r, backend);
             return proxy_status;
         }
 
@@ -1778,6 +1784,7 @@ int ap_proxy_http_process_response(apr_p
                          * left waiting for a slow client to eventually
                          * acknowledge the data.
                          */
+                        proxy_run_detach_backend(r, backend);
                         ap_proxy_release_connection(backend->worker->s->scheme,
                                 backend, r->server);
                         /* Ensure that the backend is not reused */
@@ -1816,6 +1823,7 @@ int ap_proxy_http_process_response(apr_p
              * left waiting for a slow client to eventually
              * acknowledge the data.
              */
+            proxy_run_detach_backend(r, backend);
             ap_proxy_release_connection(backend->worker->s->scheme,
                     backend, r->server);
             *backend_ptr = NULL;
@@ -1833,6 +1841,10 @@ int ap_proxy_http_process_response(apr_p
      * created from scpool and this pool can be freed before this brigade. */
     apr_brigade_cleanup(bb);
 
+    if (*backend_ptr) {
+        proxy_run_detach_backend(r, backend);
+    }
+
     /* See define of AP_MAX_INTERIM_RESPONSES for why */
     if (interim_response >= AP_MAX_INTERIM_RESPONSES) {
         return ap_proxyerror(r, HTTP_BAD_GATEWAY,
@@ -2003,6 +2015,7 @@ static int proxy_http_handler(request_re
          */
         if ((status = ap_proxy_http_request(p, r, backend, worker,
                                         conf, uri, locurl, server_portstr)) != OK) {
+            proxy_run_detach_backend(r, backend);
             if ((status == HTTP_SERVICE_UNAVAILABLE) &&
                  worker->s->ping_timeout_set &&
                  worker->s->ping_timeout >= 0) {