mirror of
https://github.com/apache/httpd.git
synced 2025-08-07 04:02:58 +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:
@@ -1253,7 +1253,7 @@ int ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
|
|||||||
const char *buf;
|
const char *buf;
|
||||||
char keepchar;
|
char keepchar;
|
||||||
apr_bucket *e;
|
apr_bucket *e;
|
||||||
apr_bucket_brigade *bb, *tmp_bb;
|
apr_bucket_brigade *bb;
|
||||||
apr_bucket_brigade *pass_bb;
|
apr_bucket_brigade *pass_bb;
|
||||||
int len, backasswards;
|
int len, backasswards;
|
||||||
int interim_response = 0; /* non-zero whilst interim 1xx responses
|
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;
|
backend->r->proxyreq = PROXYREQ_RESPONSE;
|
||||||
apr_table_setn(r->notes, "proxy-source-port", apr_psprintf(r->pool, "%hu",
|
apr_table_setn(r->notes, "proxy-source-port", apr_psprintf(r->pool, "%hu",
|
||||||
origin->local_addr->port));
|
origin->local_addr->port));
|
||||||
tmp_bb = apr_brigade_create(p, c->bucket_alloc);
|
|
||||||
do {
|
do {
|
||||||
apr_status_t rc;
|
apr_status_t rc;
|
||||||
|
|
||||||
apr_brigade_cleanup(bb);
|
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) {
|
if (len == 0) {
|
||||||
/* handle one potential stray CRLF */
|
/* 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) {
|
if (len <= 0) {
|
||||||
ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r, APLOGNO(01102)
|
ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r, APLOGNO(01102)
|
||||||
|
@@ -1298,6 +1298,7 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_balancer(proxy_balancer *balance
|
|||||||
static void socket_cleanup(proxy_conn_rec *conn)
|
static void socket_cleanup(proxy_conn_rec *conn)
|
||||||
{
|
{
|
||||||
conn->sock = NULL;
|
conn->sock = NULL;
|
||||||
|
conn->tmp_bb = NULL;
|
||||||
conn->connection = NULL;
|
conn->connection = NULL;
|
||||||
conn->ssl_hostname = NULL;
|
conn->ssl_hostname = NULL;
|
||||||
apr_pool_clear(conn->scpool);
|
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,
|
PROXY_DECLARE(apr_status_t) ap_proxy_ssl_connection_cleanup(proxy_conn_rec *conn,
|
||||||
request_rec *r)
|
request_rec *r)
|
||||||
{
|
{
|
||||||
apr_bucket_brigade *bb;
|
|
||||||
apr_status_t rv;
|
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.
|
* processed. We don't expect any data to be in the returned brigade.
|
||||||
*/
|
*/
|
||||||
if (conn->sock && conn->connection) {
|
if (conn->sock && conn->connection) {
|
||||||
bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
|
rv = ap_get_brigade(conn->connection->input_filters, conn->tmp_bb,
|
||||||
rv = ap_get_brigade(conn->connection->input_filters, bb,
|
|
||||||
AP_MODE_READBYTES, APR_NONBLOCK_READ,
|
AP_MODE_READBYTES, APR_NONBLOCK_READ,
|
||||||
HUGE_STRING_LEN);
|
HUGE_STRING_LEN);
|
||||||
if ((rv != APR_SUCCESS) && !APR_STATUS_IS_EAGAIN(rv)) {
|
if (!APR_BRIGADE_EMPTY(conn->tmp_bb)) {
|
||||||
socket_cleanup(conn);
|
|
||||||
}
|
|
||||||
if (!APR_BRIGADE_EMPTY(bb)) {
|
|
||||||
apr_off_t len;
|
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,
|
ap_log_rerror(APLOG_MARK, APLOG_TRACE3, rv, r,
|
||||||
"SSL cleanup brigade contained %"
|
"SSL cleanup brigade contained %"
|
||||||
APR_OFF_T_FMT " bytes of data.", len);
|
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;
|
return APR_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -2712,9 +2711,6 @@ PROXY_DECLARE(apr_status_t) ap_proxy_check_backend(const char *proxy_function,
|
|||||||
|
|
||||||
if (conn->connection) {
|
if (conn->connection) {
|
||||||
conn_rec *c = 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,
|
rv = ap_get_brigade(c->input_filters, conn->tmp_bb,
|
||||||
AP_MODE_SPECULATIVE, APR_NONBLOCK_READ, 1);
|
AP_MODE_SPECULATIVE, APR_NONBLOCK_READ, 1);
|
||||||
if (rv == APR_SUCCESS && expect_empty) {
|
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);
|
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
|
* The socket is now open, create a new backend server connection
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user