From a8b72c1517bdf6d7a6bee03f5e6a526337a22802 Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Fri, 2 May 2014 20:46:28 +0000 Subject: [PATCH] mod_proxy_fcgi: Fix occasional high CPU when handling request bodies. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1592037 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ modules/proxy/mod_proxy_fcgi.c | 35 ++++++++-------------------------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/CHANGES b/CHANGES index 9ed7d20c8f..4059aeaf1a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) mod_proxy_fcgi: Fix occasional high CPU when handling request bodies. + [Jeff Trawick] + *) mod_proxy_fcgi: Support iobuffersize parameter. [Jeff Trawick] *) mod_cache: Preserve non-cacheable headers forwarded from an origin 304 diff --git a/modules/proxy/mod_proxy_fcgi.c b/modules/proxy/mod_proxy_fcgi.c index fb30d8723a..d668c5424a 100644 --- a/modules/proxy/mod_proxy_fcgi.c +++ b/modules/proxy/mod_proxy_fcgi.c @@ -90,26 +90,13 @@ static int proxy_fcgi_canon(request_rec *r, char *url) static apr_status_t send_data(proxy_conn_rec *conn, struct iovec *vec, int nvec, - apr_size_t *len, - int blocking) + apr_size_t *len) { - apr_status_t rv = APR_SUCCESS, arv; + apr_status_t rv = APR_SUCCESS; apr_size_t written = 0, to_write = 0; int i, offset; - apr_interval_time_t old_timeout; apr_socket_t *s = conn->sock; - if (!blocking) { - arv = apr_socket_timeout_get(s, &old_timeout); - if (arv != APR_SUCCESS) { - return arv; - } - arv = apr_socket_timeout_set(s, 0); - if (arv != APR_SUCCESS) { - return arv; - } - } - for (i = 0; i < nvec; i++) { to_write += vec[i].iov_len; } @@ -118,7 +105,7 @@ static apr_status_t send_data(proxy_conn_rec *conn, while (to_write) { apr_size_t n = 0; rv = apr_socket_sendv(s, vec + offset, nvec - offset, &n); - if ((rv != APR_SUCCESS) && !APR_STATUS_IS_EAGAIN(rv)) { + if (rv != APR_SUCCESS) { break; } if (n > 0) { @@ -141,12 +128,6 @@ static apr_status_t send_data(proxy_conn_rec *conn, conn->worker->s->transferred += written; *len = written; - if (!blocking) { - arv = apr_socket_timeout_set(s, old_timeout); - if ((arv != APR_SUCCESS) && (rv == APR_SUCCESS)) { - return arv; - } - } return rv; } @@ -209,7 +190,7 @@ static apr_status_t send_begin_request(proxy_conn_rec *conn, vec[1].iov_base = (void *)abrb; vec[1].iov_len = sizeof(abrb); - return send_data(conn, vec, 2, &len, 1); + return send_data(conn, vec, 2, &len); } static apr_status_t send_environment(proxy_conn_rec *conn, request_rec *r, @@ -296,7 +277,7 @@ static apr_status_t send_environment(proxy_conn_rec *conn, request_rec *r, vec[1].iov_base = body; vec[1].iov_len = required_len; - rv = send_data(conn, vec, 2, &len, 1); + rv = send_data(conn, vec, 2, &len); apr_pool_clear(temp_pool); if (rv) { @@ -311,7 +292,7 @@ static apr_status_t send_environment(proxy_conn_rec *conn, request_rec *r, vec[0].iov_base = (void *)farray; vec[0].iov_len = sizeof(farray); - return send_data(conn, vec, 1, &len, 1); + return send_data(conn, vec, 1, &len); } enum { @@ -484,7 +465,7 @@ static apr_status_t dispatch(proxy_conn_rec *conn, proxy_dir_conf *conf, ++nvec; } - rv = send_data(conn, vec, nvec, &len, 0); + rv = send_data(conn, vec, nvec, &len); if (rv != APR_SUCCESS) { *err = "sending stdin"; break; @@ -505,7 +486,7 @@ static apr_status_t dispatch(proxy_conn_rec *conn, proxy_dir_conf *conf, vec[0].iov_base = (void *)farray; vec[0].iov_len = sizeof(farray); - rv = send_data(conn, vec, 1, &len, 1); + rv = send_data(conn, vec, 1, &len); if (rv != APR_SUCCESS) { *err = "sending empty stdin"; break; -- 2.40.0