fixed issue where timer could set negative value in repeat if heavily delayed

This commit is contained in:
Michael van der Werve 2019-05-02 12:08:14 +02:00
parent f7317ab4f1
commit 19d82ed1f2
1 changed files with 3 additions and 2 deletions

View File

@ -263,8 +263,9 @@ private:
// it's time for the next heartbeat
_connection->heartbeat();
// remember when we should send out the next one
_next += std::max(_timeout / 2, 1);
// remember when we should send out the next one, so the next one should be
// sent only after _timout/2 seconds again _from now_ (no catching up)
_next = now + std::max(_timeout / 2, 1);
}
// reset the timer to trigger again later