r1526189 | trawick | 2013-09-25 16:29:02 +0200 (Wed, 25 Sep 2013) | 8 lines
mod_proxy: Add ap_connection_reusable() for checking if a connection
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.
r1658765 | ylavic | 2015-02-10 18:25:54 +0100 (Tue, 10 Feb 2015) | 4 lines
mod_proxy_http: Use the "Connection: close" header for requests to
backends not recycling connections (disablereuse), including the default
reverse and forward proxies.
Reviewed by: ylavic, wrowe, rjung
Backported by: ylavic
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@
1680923 13f79535-47bb-0310-9956-
ffa450edef68
-*- coding: utf-8 -*-
Changes with Apache 2.2.30
+ *) mod_proxy_http: Use the "Connection: close" header for requests to
+ backends not recycling connections (disablereuse), including the default
+ reverse and forward proxies. [Yann Ylavic]
+
+ *) mod_proxy: Add ap_connection_reusable() for checking if a connection
+ is reusable as of this point in processing. [Jeff Trawick]
+
*) mod_proxy: Reuse proxy/balancer workers' parameters and scores across
graceful restarts, even if new workers are added, old ones removed, or
the order changes. [Jan Kaluza, Yann Ylavic]
vulnerable per se (no ErrorDocument handling from early
request line parser), better be safe than sorry.
- * mod_proxy_http: Use the "Connection: close" header for requests to
- backends not recycling connections (disablereuse), including the default
- reverse and forward proxies.
- trunk patch: http://svn.apache.org/r1526189
- http://svn.apache.org/r1658765
- 2.4.x patch: merged in http://svn.apache.org/r1673896
- 2.2.x patch: http://people.apache.org/~ylavic/httpd-2.2.x-ap_proxy_connection_reusable.patch
- +1: ylavic, wrowe, rjung
-
PATCHES PROPOSED TO BACKPORT FROM TRUNK:
[ New proposals should be added at the end of the list ]
* 20051115.36 (2.2.28) Add r->trailers_{in,out}
* 20051115.37 (2.2.30) Add ap_get_server_name_for_url()
* 20051115.38 (2.2.30) Add ap_proxy_set_scoreboard_lb() in mod_proxy.h
+ * 20051115.39 (2.2.30) Add ap_proxy_connection_reusable()
*/
#define MODULE_MAGIC_COOKIE 0x41503232UL /* "AP22" */
#ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20051115
#endif
-#define MODULE_MAGIC_NUMBER_MINOR 38 /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 39 /* 0...n */
/**
* Determine if the server's current MODULE_MAGIC_NUMBER is at least a
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
* otherwise sent Connection: Keep-Alive.
*/
if (!force10) {
- if (p_conn->close || p_conn->close_on_recycle) {
+ if (!ap_proxy_connection_reusable(p_conn)) {
buf = apr_pstrdup(p, "Connection: close" CRLF);
}
else {
return connected ? 0 : 1;
}
+PROXY_DECLARE(int) ap_proxy_connection_reusable(proxy_conn_rec *conn)
+{
+ proxy_worker *worker = conn->worker;
+
+ return ! (conn->close || conn->close_on_recycle
+ || !worker->is_address_reusable || worker->disablereuse);
+}
+
static apr_status_t connection_cleanup(void *theconn)
{
proxy_conn_rec *conn = (proxy_conn_rec *)theconn;
#endif
/* determine if the connection need to be closed */
- if (conn->close_on_recycle || conn->close || worker->disablereuse ||
- !worker->is_address_reusable) {
+ if (!ap_proxy_connection_reusable(conn)) {
apr_pool_t *p = conn->pool;
apr_pool_clear(p);
conn = apr_pcalloc(p, sizeof(proxy_conn_rec));