1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-08 15:02:10 +03:00

mod_proxy: only cleanup the socket for a connection asked to be closed but

whose address can still be reused.

This saves unnecessary socket pool destroy and creation at cleanup and reuse
time, plus the same initialization of conn->pool's associated data which can
be reused in that case.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1678763 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yann Ylavic
2015-05-11 14:53:34 +00:00
parent ecc12e3b89
commit 339e1a5943

View File

@@ -1313,6 +1313,14 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_balancer(proxy_balancer *balance
* CONNECTION related... * CONNECTION related...
*/ */
static void socket_cleanup(proxy_conn_rec *conn)
{
conn->sock = NULL;
conn->connection = NULL;
conn->ssl_hostname = NULL;
apr_pool_clear(conn->scpool);
}
static apr_status_t conn_pool_cleanup(void *theworker) static apr_status_t conn_pool_cleanup(void *theworker)
{ {
proxy_worker *worker = (proxy_worker *)theworker; proxy_worker *worker = (proxy_worker *)theworker;
@@ -1379,7 +1387,7 @@ static apr_status_t connection_cleanup(void *theconn)
} }
/* determine if the connection need to be closed */ /* determine if the connection need to be closed */
if (!ap_proxy_connection_reusable(conn)) { if (!worker->s->is_address_reusable || worker->s->disablereuse) {
apr_pool_t *p = conn->pool; apr_pool_t *p = conn->pool;
apr_pool_clear(p); apr_pool_clear(p);
conn = apr_pcalloc(p, sizeof(proxy_conn_rec)); conn = apr_pcalloc(p, sizeof(proxy_conn_rec));
@@ -1388,6 +1396,10 @@ static apr_status_t connection_cleanup(void *theconn)
apr_pool_create(&(conn->scpool), p); apr_pool_create(&(conn->scpool), p);
apr_pool_tag(conn->scpool, "proxy_conn_scpool"); apr_pool_tag(conn->scpool, "proxy_conn_scpool");
} }
else if (conn->close) {
socket_cleanup(conn);
conn->close = 0;
}
if (worker->s->hmax && worker->cp->res) { if (worker->s->hmax && worker->cp->res) {
conn->inreslist = 1; conn->inreslist = 1;
@@ -1402,14 +1414,6 @@ static apr_status_t connection_cleanup(void *theconn)
return APR_SUCCESS; return APR_SUCCESS;
} }
static void socket_cleanup(proxy_conn_rec *conn)
{
conn->sock = NULL;
conn->connection = NULL;
conn->ssl_hostname = NULL;
apr_pool_clear(conn->scpool);
}
PROXY_DECLARE(apr_status_t) ap_proxy_ssl_connection_cleanup(proxy_conn_rec *conn, PROXY_DECLARE(apr_status_t) ap_proxy_ssl_connection_cleanup(proxy_conn_rec *conn,
request_rec *r) request_rec *r)
{ {
@@ -2817,9 +2821,9 @@ PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
proxy_function, backend_addr->family, worker->s->hostname); proxy_function, backend_addr->family, worker->s->hostname);
if (conf->source_address_set) { if (conf->source_address_set) {
local_addr = apr_pmemdup(conn->pool, conf->source_address, local_addr = apr_pmemdup(conn->scpool, conf->source_address,
sizeof(apr_sockaddr_t)); sizeof(apr_sockaddr_t));
local_addr->pool = conn->pool; local_addr->pool = conn->scpool;
rv = apr_socket_bind(newsock, local_addr); rv = apr_socket_bind(newsock, local_addr);
if (rv != APR_SUCCESS) { if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00956) ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00956)