8335b1
diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h
8335b1
index 81fd14c..cd1710f 100644
8335b1
--- a/modules/proxy/mod_proxy.h
8335b1
+++ b/modules/proxy/mod_proxy.h
8335b1
@@ -856,6 +856,17 @@ PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
8335b1
 PROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function,
8335b1
                                               proxy_conn_rec *conn,
8335b1
                                               conn_rec *c, server_rec *s);
8335b1
+
8335b1
+/**
8335b1
+ * Determine if proxy connection can potentially be reused at the
8335b1
+ * end of this request.
8335b1
+ * @param conn proxy connection
8335b1
+ * @return non-zero if reusable, 0 otherwise
8335b1
+ * @note Even if this function returns non-zero, the connection may
8335b1
+ * be subsequently marked for closure.
8335b1
+ */
8335b1
+PROXY_DECLARE(int) ap_proxy_connection_reusable(proxy_conn_rec *conn);
8335b1
+
8335b1
 /**
8335b1
  * Signal the upstream chain that the connection to the backend broke in the
8335b1
  * middle of the response. This is done by sending an error bucket with
8335b1
diff --git a/modules/proxy/mod_proxy_fcgi.c b/modules/proxy/mod_proxy_fcgi.c
8335b1
index 0f84416..c57696a 100644
8335b1
--- a/modules/proxy/mod_proxy_fcgi.c
8335b1
+++ b/modules/proxy/mod_proxy_fcgi.c
8335b1
@@ -247,7 +247,7 @@ static apr_status_t send_begin_request(proxy_conn_rec *conn, int request_id)
8335b1
 
8335b1
     brb.roleB1 = ((FCGI_RESPONDER >> 8) & 0xff);
8335b1
     brb.roleB0 = ((FCGI_RESPONDER) & 0xff);
8335b1
-    brb.flags = FCGI_KEEP_CONN;
8335b1
+    brb.flags = ap_proxy_connection_reusable(conn) ? FCGI_KEEP_CONN : 0;
8335b1
     brb.reserved[0] = 0;
8335b1
     brb.reserved[1] = 0;
8335b1
     brb.reserved[2] = 0;
8335b1
diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c
8335b1
index 8bc9fab..ca70ae4 100644
8335b1
--- a/modules/proxy/proxy_util.c
8335b1
+++ b/modules/proxy/proxy_util.c
8335b1
@@ -1333,6 +1333,13 @@ static void init_conn_pool(apr_pool_t *p, proxy_worker *worker)
8335b1
     worker->cp = cp;
8335b1
 }
8335b1
 
8335b1
+PROXY_DECLARE(int) ap_proxy_connection_reusable(proxy_conn_rec *conn)
8335b1
+{
8335b1
+    proxy_worker *worker = conn->worker;
8335b1
+
8335b1
+    return ! (conn->close || !worker->s->is_address_reusable || worker->s->disablereuse);
8335b1
+}
8335b1
+
8335b1
 static apr_status_t connection_cleanup(void *theconn)
8335b1
 {
8335b1
     proxy_conn_rec *conn = (proxy_conn_rec *)theconn;
8335b1
@@ -1361,7 +1368,7 @@ static apr_status_t connection_cleanup(void *theconn)
8335b1
     }
8335b1
 
8335b1
     /* determine if the connection need to be closed */
8335b1
-    if (conn->close || !worker->s->is_address_reusable || worker->s->disablereuse) {
8335b1
+    if (!ap_proxy_connection_reusable(conn)) {
8335b1
         apr_pool_t *p = conn->pool;
8335b1
         apr_pool_clear(p);
8335b1
         conn = apr_pcalloc(p, sizeof(proxy_conn_rec));