Skip to content

Commit

Permalink
Do not publish the event if the keepalive interval has not changed
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeuz committed Oct 2, 2019
1 parent 1ca9e79 commit ac0c73f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions communication/src/ping.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions system/src/system_cloud_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,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);
Expand Down

0 comments on commit ac0c73f

Please sign in to comment.