From 7df5c4000438a998e5a6dab14d58fc04907f543c Mon Sep 17 00:00:00 2001 From: Pierre Fersing Date: Tue, 2 Jan 2018 16:50:47 +0100 Subject: [PATCH] Fix $SYS counters when message is sent over WS Signed-off-by: Pierre Fersing --- ChangeLog.txt | 2 ++ src/websockets.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 7c7ff363..7bb2e79e 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -9,6 +9,8 @@ Broker: - Fix 08-ssl-bridge.py test when using async dns lookups. Closes #507. - Lines in the config file are no longer limited to 1024 characters long. Closes #652. +- Fix $SYS counters of messages and bytes sent when message is sent over + a Websockets. Closes #250. Client library: - Fix incorrect PSK key being used if it had leading zeroes. diff --git a/src/websockets.c b/src/websockets.c index 5fdf12b3..5ae84fd5 100644 --- a/src/websockets.c +++ b/src/websockets.c @@ -285,12 +285,22 @@ static int callback_mqtt(struct libwebsocket_context *context, if(count < 0){ return 0; } +#ifdef WITH_SYS_TREE + g_bytes_sent += count; +#endif packet->to_process -= count; packet->pos += count; if(packet->to_process > 0){ break; } +#ifdef WITH_SYS_TREE + g_msgs_sent++; + if(((packet->command)&0xF6) == PUBLISH){ + g_pub_msgs_sent++; + } +#endif + /* Free data and reset values */ mosq->current_out_packet = mosq->out_packet; if(mosq->out_packet){