]> granicus.if.org Git - apache/commitdiff
mod_proxy: Shutdown (eg. close notify) the backend connection before closing.
authorYann Ylavic <ylavic@apache.org>
Mon, 9 Jun 2014 00:23:16 +0000 (00:23 +0000)
committerYann Ylavic <ylavic@apache.org>
Mon, 9 Jun 2014 00:23:16 +0000 (00:23 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1601285 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 b7749b7844d0b95439b4f0b0a141c0a1f8322675..45df99dcadb9d0a0dade12668d8b8e0694ec2569 100644 (file)
@@ -1 +1 @@
-2706
+2707
index 5bd9a4b2a42e6796b78bd5f0e40703a20c9558e1..203917d7e7384af292770b1da12b0a18a94f1a53 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(02706)
+                      "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;
 }