diff options
author | Jean-Frederic Clere <jfclere@apache.org> | 2021-05-06 06:25:09 +0000 |
---|---|---|
committer | Jean-Frederic Clere <jfclere@apache.org> | 2021-05-06 06:25:09 +0000 |
commit | cfd93e6c706e6119274cb10c3fcd0279e4b03759 (patch) | |
tree | 631c77de2b57944f1fe8d07c29e698f9882133ec | |
parent | 1153a2d5d3ecbb3389fdbc4e5d3fd25e1c412c44 (diff) | |
download | httpd-cfd93e6c706e6119274cb10c3fcd0279e4b03759.tar.gz |
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
-rw-r--r-- | include/ap_mmn.h | 5 | ||||
-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 |
4 files changed, 39 insertions, 10 deletions
diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 260aca246d..5e2634be37 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -669,12 +669,15 @@ * 20201214.3 (2.5.1-dev) Move ap_ssl_* into new http_ssl.h header file * 20201214.4 (2.5.1-dev) Add ap_ssl_ocsp* hooks and functions to http_ssl.h. * 20210420.0 (2.5.1-dev) Removed `ap_bytes_t` again from httpd.h and usage in ap_ssl_ocsp*() + * 20210506.0 (2.5.1-dev) Add ap_proxy_tunnel_conn_get_read() and + * ap_proxy_tunnel_conn_get_transferred() change + * ap_proxy_transfer_between_connections() sent to apr_off_t *. */ #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */ #ifndef MODULE_MAGIC_NUMBER_MAJOR -#define MODULE_MAGIC_NUMBER_MAJOR 20210420 +#define MODULE_MAGIC_NUMBER_MAJOR 20210506 #endif #define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */ 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 |