Fix UB due to integer overflow

This commit is contained in:
Tyler Neely 2022-11-03 13:27:45 +00:00
parent 0364311dd0
commit 2de1d6c359

View File

@ -581,7 +581,7 @@ class Raft {
const Time now = io_.Now();
const Duration broadcast_timeout = RandomTimeout(kMinimumBroadcastTimeout, kMaximumBroadcastTimeout);
if (now - leader.last_broadcast > broadcast_timeout) {
if (now > leader.last_broadcast + broadcast_timeout) {
BroadcastAppendEntries(leader.followers);
leader.last_broadcast = now;
}