]> granicus.if.org Git - apache/commitdiff
mod_proxy: Add ap_connection_reusable() for checking if a connection
authorJeff Trawick <trawick@apache.org>
Wed, 25 Sep 2013 14:29:02 +0000 (14:29 +0000)
committerJeff Trawick <trawick@apache.org>
Wed, 25 Sep 2013 14:29:02 +0000 (14:29 +0000)
is reusable as of this point in processing.

mod_proxy_fcgi uses the new API to determine if FCGI_CONN_CLOSE
should be enabled, but that doesn't change existing behavior
since the connection is currently marked for closure elsewhere
in the module.

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

CHANGES
include/ap_mmn.h
modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_fcgi.c
modules/proxy/proxy_util.c

diff --git a/CHANGES b/CHANGES
index 232e77370807978dca72ad946811042f239c0fe4..bd7bedc48be9e601aca6c0276bfe92bb1a8eceea 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) mod_proxy: Add ap_connection_reusable() for checking if a connection
+     is reusable as of this point in processing.  [Jeff Trawick]
+
   *) mod_ssl: drop support for export-grade ciphers with ephemeral RSA
      keys, and unconditionally disable aNULL, eNULL and EXP ciphers
      (not overridable via SSLCipherSuite). [Kaspar Brand]
index a7f5fa5c32a61eb3f0a62aa400486c95ad87f044..baee00df216bb5cb171880e64b44c8bb95b75946 100644 (file)
  * 20130702.3 (2.5.0-dev)  Add util_fcgi.h, FastCGI protocol support
  * 20130903.0 (2.5.0-dev)  Changes sizeof(worker_score) in scoreboard 
  * 20130924.0 (2.5.0-dev)  Add ap_errorlog_provider
+ * 20130924.1 (2.5.0-dev)  Add ap_proxy_connection_reusable()
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20130924
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 0                  /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 1                  /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index e36f3f734cee5203511822df230c20a23be3ef85..8dce385dcb38a6580f4f32c25db46ea4bd25b0ef 100644 (file)
@@ -857,6 +857,17 @@ PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
 PROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function,
                                               proxy_conn_rec *conn,
                                               conn_rec *c, server_rec *s);
+
+/**
+ * Determine if proxy connection can potentially be reused at the
+ * end of this request.
+ * @param conn proxy connection
+ * @return non-zero if reusable, 0 otherwise
+ * @note Even if this function returns non-zero, the connection may
+ * be subsequently marked for closure.
+ */
+PROXY_DECLARE(int) ap_proxy_connection_reusable(proxy_conn_rec *conn);
+
 /**
  * Signal the upstream chain that the connection to the backend broke in the
  * middle of the response. This is done by sending an error bucket with
index ee7029002ca5fd70dad245c46fef4f6211185221..56c9c3745632bd12771bd39a3c52b2ac9e9fbdcf 100644 (file)
@@ -193,7 +193,9 @@ static apr_status_t send_begin_request(proxy_conn_rec *conn,
     ap_fcgi_fill_in_header(&header, AP_FCGI_BEGIN_REQUEST, request_id,
                            sizeof(abrb), 0);
 
-    ap_fcgi_fill_in_request_body(&brb, AP_FCGI_RESPONDER, AP_FCGI_KEEP_CONN);
+    ap_fcgi_fill_in_request_body(&brb, AP_FCGI_RESPONDER,
+                                 ap_proxy_connection_reusable(conn)
+                                     ? AP_FCGI_KEEP_CONN : 0);
 
     ap_fcgi_header_to_array(&header, farray);
     ap_fcgi_begin_request_body_to_array(&brb, abrb);
index 58fa00d9a75e087f428ae7f7086d4787f9e233b2..d2f7b70e8eec6304bc819ccaa881ea5f2a3b0f7b 100644 (file)
@@ -1334,6 +1334,13 @@ static void init_conn_pool(apr_pool_t *p, proxy_worker *worker)
     worker->cp = cp;
 }
 
+PROXY_DECLARE(int) ap_proxy_connection_reusable(proxy_conn_rec *conn)
+{
+    proxy_worker *worker = conn->worker;
+
+    return ! (conn->close || !worker->s->is_address_reusable || worker->s->disablereuse);
+}
+
 static apr_status_t connection_cleanup(void *theconn)
 {
     proxy_conn_rec *conn = (proxy_conn_rec *)theconn;
@@ -1362,7 +1369,7 @@ static apr_status_t connection_cleanup(void *theconn)
     }
 
     /* determine if the connection need to be closed */
-    if (conn->close || !worker->s->is_address_reusable || worker->s->disablereuse) {
+    if (!ap_proxy_connection_reusable(conn)) {
         apr_pool_t *p = conn->pool;
         apr_pool_clear(p);
         conn = apr_pcalloc(p, sizeof(proxy_conn_rec));