From 3c8b4e4994e7fa8922b0175ccd5fb94872a03402 Mon Sep 17 00:00:00 2001 From: Sergey Polyakov Date: Fri, 6 Sep 2019 13:32:18 +0200 Subject: [PATCH] Do not publish the event if the keepalive interval has not changed --- communication/src/ping.h | 6 ++++-- system/src/system_cloud_internal.cpp | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/communication/src/ping.h b/communication/src/ping.h index 929ac1f78e..1dd7d55a05 100644 --- a/communication/src/ping.h +++ b/communication/src/ping.h @@ -45,9 +45,11 @@ class Pinger // TODO: It feels that this logic should have been implemented in the system layer if ( !(this->keepalive_source == KeepAliveSource::USER && source == KeepAliveSource::SYSTEM) ) { - this->ping_interval = interval; this->keepalive_source = source; - return true; + if (this->ping_interval != interval) { + this->ping_interval = interval; + return true; + } } return false; } diff --git a/system/src/system_cloud_internal.cpp b/system/src/system_cloud_internal.cpp index 2f153954e5..8adae82dd6 100644 --- a/system/src/system_cloud_internal.cpp +++ b/system/src/system_cloud_internal.cpp @@ -1130,6 +1130,9 @@ bool publishKeepaliveInterval(unsigned interval) { return false; } } + // TODO: Even though the keepalive interval is not supposed to be changed frequently, it would be + // nice to make sure the previously published event is either sent or cancelled before publishing + // a new event. This would help to mitigate the effect of possible out of order delivery char buf[16] = {}; snprintf(buf, sizeof(buf), "%u", interval); return publishEvent(KEEPALIVE_INTERVAL_EVENT, buf);