summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/src/tcp_stream.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/platform/src/tcp_stream.cpp b/platform/src/tcp_stream.cpp
index 01b77c0..70cdb1a 100644
--- a/platform/src/tcp_stream.cpp
+++ b/platform/src/tcp_stream.cpp
@@ -597,21 +597,19 @@ static void __stream_bev_readcb(struct bufferevent * bev, void * arg)
struct tfe_conn_private * peer_conn = NULL;
struct evbuffer * inbuf = NULL;
struct evbuffer * outbuf = NULL;
+ int inbuff_len = 0;
if (steering_device_is_available() && (
(STREAM_PROTO_PLAIN == _stream->session_type && _stream->proxy_ref->traffic_steering_options.enable_steering_http) ||
(STREAM_PROTO_SSL == _stream->session_type &&_stream->proxy_ref->traffic_steering_options.enable_steering_ssl)))
{
- enum TFE_STAT_FIELD stat_filed = TFE_STAT_MAX;
if (bev == _stream->conn_downstream->bev)
{
peer_conn = _stream->conn_fake_c;
- stat_filed = STAT_STEERING_CLIENT_TX_B;
}
else if (bev == _stream->conn_upstream->bev)
{
peer_conn = _stream->conn_fake_s;
- stat_filed = STAT_STEERING_SERVER_TX_B;
}
else
{
@@ -623,22 +621,39 @@ static void __stream_bev_readcb(struct bufferevent * bev, void * arg)
* This connection will be destoryed in __event_cb
*/
inbuf = bufferevent_get_input(bev);
+ inbuff_len = evbuffer_get_length(inbuf);
if (peer_conn == NULL)
{
- evbuffer_drain(inbuf, evbuffer_get_length(inbuf));
+ evbuffer_drain(inbuf, inbuff_len);
return;
}
TFE_LOG_DEBUG(__STREAM_LOGGER(_stream), "decrypted traffic steering, %s send %d bytes from %s to %s",
_stream->str_stream_addr,
- evbuffer_get_length(inbuf),
+ inbuff_len,
bev == _stream->conn_downstream->bev ? "conn_downstream" : "conn_upstream",
bev == _stream->conn_downstream->bev ? "conn_fake_c" : "conn_fake_s");
- TFE_PROXY_STAT_INCREASE(stat_filed, evbuffer_get_length(inbuf));
outbuf = bufferevent_get_output(peer_conn->bev);
evbuffer_add_buffer(outbuf, inbuf);
+ if (bev == _stream->conn_downstream->bev)
+ {
+ TFE_PROXY_STAT_INCREASE(STAT_STEERING_CLIENT_TX_B, inbuff_len);
+ // TODO: Delete the following code when support calling the tfe-plugin
+ TFE_PROXY_STAT_INCREASE(STAT_STREAM_INCPT_DOWN_BYTES, inbuff_len);
+ _stream->downstream_rx_offset += inbuff_len;
+ }
+ else
+ {
+ TFE_PROXY_STAT_INCREASE(STAT_STEERING_SERVER_TX_B, inbuff_len);
+ // TODO: Delete the following code when support calling the tfe-plugin
+ TFE_PROXY_STAT_INCREASE(STAT_STREAM_INCPT_UP_BYTES, inbuff_len);
+ _stream->upstream_rx_offset += inbuff_len;
+ }
+
+ // TODO: Delete the following code when support calling the tfe-plugin
+ TFE_PROXY_STAT_INCREASE(STAT_STREAM_INCPT_BYTES, inbuff_len);
return;
}