]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Allow the tunnelled connections to report the
authorJean-Frederic Clere <jfclere@apache.org>
Thu, 6 May 2021 06:25:09 +0000 (06:25 +0000)
committerJean-Frederic Clere <jfclere@apache.org>
Thu, 6 May 2021 06:25:09 +0000 (06:25 +0000)
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

include/ap_mmn.h
modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_http.c
modules/proxy/proxy_util.c

index 260aca246d8c361aad40bf5b498fb46b29a21455..5e2634be3727ff862e15a40ed9d5af9cf592b074 100644 (file)
  * 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 */
 
index 0e398a5bb2aecb4bca0c03cdc4ff4299de4fef01..acc8cab4bb494ff7d13e6e07816b4148b16cd4cb 100644 (file)
@@ -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*/
index d32b14e3f0e1872376b3bc98b85f45edf0577547..056cfb1f7777dd02fe9fbfe9fb3247e1a4d5ef5c 100644 (file)
@@ -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;
index cc8e8c4a41e4756b9487870af86738fc7301ab25..6b896408eafa98fe2c26b24d369d83599da69bfc 100644 (file)
@@ -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