Hi,
I have noted that when using websocket the bytes read and transfered by
the worker when using the tunnel are not taken in account.
I have a patch attached, for comments ;-)
Any better ideas how to fix that?
--
Cheers
Jean-Frederic
Index: mod_proxy.h
===================================================================
--- mod_proxy.h (revision 1889510)
+++ mod_proxy.h (working copy)
@@ -1470,10 +1470,25 @@
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: mod_proxy_http.c
===================================================================
--- mod_proxy_http.c (revision 1889510)
+++ mod_proxy_http.c (working copy)
@@ -1542,6 +1542,8 @@
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: proxy_util.c
===================================================================
--- proxy_util.c (revision 1889510)
+++ proxy_util.c (working copy)
@@ -4404,7 +4404,7 @@
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)
{
@@ -4411,9 +4411,7 @@
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,7 +4454,6 @@
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)
@@ -4463,9 +4460,8 @@
"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 @@
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 @@
{
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 @@
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