]> granicus.if.org Git - apache/commitdiff
mod_proxy: Shutdown (eg. SSL close notify) the backend connection
authorYann Ylavic <ylavic@apache.org>
Mon, 9 Jun 2014 01:03:39 +0000 (01:03 +0000)
committerYann Ylavic <ylavic@apache.org>
Mon, 9 Jun 2014 01:03:39 +0000 (01:03 +0000)
before closing.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1601291 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
docs/log-message-tags/next-number
modules/proxy/proxy_util.c

diff --git a/CHANGES b/CHANGES
index 52af761c883757a7d90a7888c13f7f3996160ad1..b87c8b692f0da18b0580e3cb5f2dbee647a4de22 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) mod_proxy: Shutdown (eg. close notify) the backend connection before
+     closing. [Yann Ylavic] 
+
   *) mpm_event[opt]: Send the SSL close notify alert when the KeepAliveTimeout
      expires. PR54998. [Yann Ylavic] 
 
index f570f1c66fdcbea0d16ba619f13e7b5123efb4a9..a54a3cb83cbbcac6c7110cd6eb4f6104c336a3d2 100644 (file)
@@ -1 +1 @@
-2642
+2643
index 5bd9a4b2a42e6796b78bd5f0e40703a20c9558e1..513b8657197a7c683ad009c78b4e9d745376e661 100644 (file)
@@ -2815,6 +2815,33 @@ PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
     return connected ? OK : DECLINED;
 }
 
+static apr_status_t connection_shutdown(void *theconn)
+{
+    proxy_conn_rec *conn = (proxy_conn_rec *)theconn;
+    conn_rec *c = conn->connection;
+    if (c) {
+        if (!c->aborted) {
+            apr_interval_time_t saved_timeout = 0;
+            apr_socket_timeout_get(conn->sock, &saved_timeout);
+            if (saved_timeout) {
+                apr_socket_timeout_set(conn->sock, 0);
+            }
+
+            (void)ap_shutdown_conn(c, 0);
+            c->aborted = 1;
+
+            if (saved_timeout) {
+                apr_socket_timeout_set(conn->sock, saved_timeout);
+            }
+        }
+
+        ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, c, APLOGNO(02642)
+                      "proxy: connection shutdown");
+    }
+    return APR_SUCCESS;
+}
+
+
 PROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function,
                                               proxy_conn_rec *conn,
                                               conn_rec *c,
@@ -2887,6 +2914,12 @@ PROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function,
     }
     apr_socket_timeout_set(conn->sock, current_timeout);
 
+    /* Shutdown the connection before closing it (eg. SSL connections
+     * need to be close-notify-ed).
+     */
+    apr_pool_cleanup_register(conn->scpool, conn, connection_shutdown,
+                              apr_pool_cleanup_null);
+
     return OK;
 }