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

mod_proxy: use proxy_conn_rec->tmp_bb where appopriate to avoid temporary

brigade create/destroy.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1750412 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yann Ylavic
2016-06-27 21:39:53 +00:00
parent 86a096011a
commit bc73d63b45
2 changed files with 14 additions and 16 deletions

View File

@@ -1253,7 +1253,7 @@ int ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
const char *buf;
char keepchar;
apr_bucket *e;
apr_bucket_brigade *bb, *tmp_bb;
apr_bucket_brigade *bb;
apr_bucket_brigade *pass_bb;
int len, backasswards;
int interim_response = 0; /* non-zero whilst interim 1xx responses
@@ -1306,16 +1306,17 @@ int ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
backend->r->proxyreq = PROXYREQ_RESPONSE;
apr_table_setn(r->notes, "proxy-source-port", apr_psprintf(r->pool, "%hu",
origin->local_addr->port));
tmp_bb = apr_brigade_create(p, c->bucket_alloc);
do {
apr_status_t rc;
apr_brigade_cleanup(bb);
rc = ap_proxygetline(tmp_bb, buffer, sizeof(buffer), backend->r, 0, &len);
rc = ap_proxygetline(backend->tmp_bb, buffer, sizeof(buffer),
backend->r, 0, &len);
if (len == 0) {
/* handle one potential stray CRLF */
rc = ap_proxygetline(tmp_bb, buffer, sizeof(buffer), backend->r, 0, &len);
rc = ap_proxygetline(backend->tmp_bb, buffer, sizeof(buffer),
backend->r, 0, &len);
}
if (len <= 0) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r, APLOGNO(01102)

View File

@@ -1298,6 +1298,7 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_balancer(proxy_balancer *balance
static void socket_cleanup(proxy_conn_rec *conn)
{
conn->sock = NULL;
conn->tmp_bb = NULL;
conn->connection = NULL;
conn->ssl_hostname = NULL;
apr_pool_clear(conn->scpool);
@@ -1401,7 +1402,6 @@ static apr_status_t connection_cleanup(void *theconn)
PROXY_DECLARE(apr_status_t) ap_proxy_ssl_connection_cleanup(proxy_conn_rec *conn,
request_rec *r)
{
apr_bucket_brigade *bb;
apr_status_t rv;
/*
@@ -1413,22 +1413,21 @@ PROXY_DECLARE(apr_status_t) ap_proxy_ssl_connection_cleanup(proxy_conn_rec *conn
* processed. We don't expect any data to be in the returned brigade.
*/
if (conn->sock && conn->connection) {
bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
rv = ap_get_brigade(conn->connection->input_filters, bb,
rv = ap_get_brigade(conn->connection->input_filters, conn->tmp_bb,
AP_MODE_READBYTES, APR_NONBLOCK_READ,
HUGE_STRING_LEN);
if ((rv != APR_SUCCESS) && !APR_STATUS_IS_EAGAIN(rv)) {
socket_cleanup(conn);
}
if (!APR_BRIGADE_EMPTY(bb)) {
if (!APR_BRIGADE_EMPTY(conn->tmp_bb)) {
apr_off_t len;
rv = apr_brigade_length(bb, 0, &len);
rv = apr_brigade_length(conn->tmp_bb, 0, &len);
ap_log_rerror(APLOG_MARK, APLOG_TRACE3, rv, r,
"SSL cleanup brigade contained %"
APR_OFF_T_FMT " bytes of data.", len);
apr_brigade_cleanup(conn->tmp_bb);
}
if ((rv != APR_SUCCESS) && !APR_STATUS_IS_EAGAIN(rv)) {
socket_cleanup(conn);
}
apr_brigade_destroy(bb);
}
return APR_SUCCESS;
}
@@ -2712,9 +2711,6 @@ PROXY_DECLARE(apr_status_t) ap_proxy_check_backend(const char *proxy_function,
if (conn->connection) {
conn_rec *c = conn->connection;
if (conn->tmp_bb == NULL) {
conn->tmp_bb = apr_brigade_create(c->pool, c->bucket_alloc);
}
rv = ap_get_brigade(c->input_filters, conn->tmp_bb,
AP_MODE_SPECULATIVE, APR_NONBLOCK_READ, 1);
if (rv == APR_SUCCESS && expect_empty) {
@@ -3046,6 +3042,7 @@ static int proxy_connection_create(const char *proxy_function,
}
bucket_alloc = apr_bucket_alloc_create(conn->scpool);
conn->tmp_bb = apr_brigade_create(conn->scpool, bucket_alloc);
/*
* The socket is now open, create a new backend server connection
*/