diff options
author | Jean-Frederic Clere <jfclere@apache.org> | 2021-05-06 08:25:09 +0200 |
---|---|---|
committer | Jean-Frederic Clere <jfclere@apache.org> | 2021-05-06 08:25:09 +0200 |
commit | cfd93e6c706e6119274cb10c3fcd0279e4b03759 (patch) | |
tree | 631c77de2b57944f1fe8d07c29e698f9882133ec /modules/proxy | |
parent | Add some missing space in HTML (diff) | |
download | apache2-cfd93e6c706e6119274cb10c3fcd0279e4b03759.tar.xz apache2-cfd93e6c706e6119274cb10c3fcd0279e4b03759.zip |
Allow the tunnelled connections to report the
read and trasnfered to the back-end worker.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1889550 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/proxy')
-rw-r--r-- | modules/proxy/mod_proxy.h | 17 | ||||
-rw-r--r-- | modules/proxy/mod_proxy_http.c | 2 | ||||
-rw-r--r-- | modules/proxy/proxy_util.c | 25 |
3 files changed, 35 insertions, 9 deletions
diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index 0e398a5bb2..acc8cab4bb 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -1470,10 +1470,25 @@ PROXY_DECLARE(apr_status_t) ap_proxy_transfer_between_connections( apr_bucket_brigade *bb_i, apr_bucket_brigade *bb_o, const char *name, - int *sent, + apr_off_t *sent, apr_off_t bsize, int flags); +/* + * returns number of bytes read from the back end tunnel + * @param ptunnel proxy_tunnel_rec use during the tunnelling. + * @return apr_off_t number of bytes read. + */ +PROXY_DECLARE (apr_off_t) ap_proxy_tunnel_conn_get_read( + proxy_tunnel_rec *ptunnel); +/* + * returns number of bytes sent to the back end tunnel + * @param ptunnel proxy_tunnel_rec use during the tunnelling. + * @return apr_off_t number of bytes sent. + */ +PROXY_DECLARE (apr_off_t) ap_proxy_tunnel_conn_get_transferred( + proxy_tunnel_rec *ptunnel); + extern module PROXY_DECLARE_DATA proxy_module; #endif /*MOD_PROXY_H*/ diff --git a/modules/proxy/mod_proxy_http.c b/modules/proxy/mod_proxy_http.c index d32b14e3f0..056cfb1f77 100644 --- a/modules/proxy/mod_proxy_http.c +++ b/modules/proxy/mod_proxy_http.c @@ -1542,6 +1542,8 @@ int ap_proxy_http_process_response(proxy_http_req_t *req) r->status = status; } + backend->worker->s->read = backend->worker->s->read + ap_proxy_tunnel_conn_get_read(req->tunnel); + backend->worker->s->transferred = backend->worker->s->transferred + ap_proxy_tunnel_conn_get_transferred(req->tunnel); /* We are done with both connections */ r->connection->keepalive = AP_CONN_CLOSE; backend->close = 1; diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index cc8e8c4a41..6b896408ea 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -4404,16 +4404,14 @@ PROXY_DECLARE(apr_status_t) ap_proxy_transfer_between_connections( apr_bucket_brigade *bb_i, apr_bucket_brigade *bb_o, const char *name, - int *sent, + apr_off_t *sent, apr_off_t bsize, int flags) { apr_status_t rv; int flush_each = 0; unsigned int num_reads = 0; -#ifdef DEBUGGING apr_off_t len; -#endif /* * Compat: since FLUSH_EACH is default (and zero) for legacy reasons, we @@ -4456,16 +4454,14 @@ PROXY_DECLARE(apr_status_t) ap_proxy_transfer_between_connections( if (APR_BRIGADE_EMPTY(bb_i)) { break; } -#ifdef DEBUGGING len = -1; apr_brigade_length(bb_i, 0, &len); ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(03306) "ap_proxy_transfer_between_connections: " "read %" APR_OFF_T_FMT " bytes from %s", len, name); -#endif - if (sent) { - *sent = 1; + if (sent && len > 0) { + *sent = *sent + len; } ap_proxy_buckets_lifetime_transform(r, bb_i, bb_o); if (flush_each) { @@ -4559,8 +4555,18 @@ struct proxy_tunnel_conn { unsigned int down_in:1, down_out:1; + apr_off_t exchanged; }; +PROXY_DECLARE(apr_off_t) ap_proxy_tunnel_conn_get_read(proxy_tunnel_rec *ptunnel) +{ + return ptunnel->origin->exchanged; +} +PROXY_DECLARE(apr_off_t) ap_proxy_tunnel_conn_get_transferred(proxy_tunnel_rec *ptunnel) +{ + return ptunnel->client->exchanged; +} + PROXY_DECLARE(apr_status_t) ap_proxy_tunnel_create(proxy_tunnel_rec **ptunnel, request_rec *r, conn_rec *c_o, const char *scheme) @@ -4693,7 +4699,7 @@ static int proxy_tunnel_forward(proxy_tunnel_rec *tunnel, { struct proxy_tunnel_conn *out = in->other; apr_status_t rv; - int sent = 0; + apr_off_t sent = 0; ap_log_rerror(APLOG_MARK, APLOG_TRACE8, 0, tunnel->r, "proxy: %s: %s input ready", @@ -4709,6 +4715,9 @@ static int proxy_tunnel_forward(proxy_tunnel_rec *tunnel, if (sent && out == tunnel->client) { tunnel->replied = 1; } + + in->exchanged = in->exchanged + sent; + if (rv != APR_SUCCESS) { if (APR_STATUS_IS_INCOMPLETE(rv)) { /* Pause POLLIN while waiting for POLLOUT on the other |