You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2014/06/09 02:23:17 UTC

svn commit: r1601285 - in /httpd/httpd/trunk: CHANGES docs/log-message-tags/next-number modules/proxy/proxy_util.c

Author: ylavic
Date: Mon Jun  9 00:23:16 2014
New Revision: 1601285

URL: http://svn.apache.org/r1601285
Log:
mod_proxy: Shutdown (eg. close notify) the backend connection before closing.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/docs/log-message-tags/next-number
    httpd/httpd/trunk/modules/proxy/proxy_util.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1601285&r1=1601284&r2=1601285&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Mon Jun  9 00:23:16 2014
@@ -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] 
 

Modified: httpd/httpd/trunk/docs/log-message-tags/next-number
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/log-message-tags/next-number?rev=1601285&r1=1601284&r2=1601285&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/log-message-tags/next-number (original)
+++ httpd/httpd/trunk/docs/log-message-tags/next-number Mon Jun  9 00:23:16 2014
@@ -1 +1 @@
-2706
+2707

Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=1601285&r1=1601284&r2=1601285&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Mon Jun  9 00:23:16 2014
@@ -2815,6 +2815,33 @@ PROXY_DECLARE(int) ap_proxy_connect_back
     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_c
     }
     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;
 }