Commit 67b7c1a1 authored by Charlie Andrews's avatar Charlie Andrews Committed by Commit Bot

Cancel the BattOr agent action timeout as soon as a message is read

Before this change, the timeout callback was only cancelled if the
message was successfuly read. This caused problems when the message
*wasn't* successfully read: the action would be scheduled to be retried
in two seconds, but before that two seconds elapsed, the timeout would
trigger and we'd say that the action failed due to a timeout, without
ever having retried it.

Cancelling the timeout unconditionally should be the right thing to do
here: after all, the timeout is intended to prevent nothing from
happening for an extended period of time and, in the case that a
bad message was read, something *did* happen, it just wasn't good.

Bug: 775520
Change-Id: I9ac7c4cfb9f12e50af07a1f8011a2495447a2f40
Reviewed-on: https://chromium-review.googlesource.com/726304Reviewed-by: default avatarrnephew <rnephew@chromium.org>
Commit-Queue: Charlie Andrews <charliea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#509863}
parent 380a395a
......@@ -212,6 +212,8 @@ void BattOrAgent::OnBytesSent(bool success) {
void BattOrAgent::OnMessageRead(bool success,
BattOrMessageType type,
std::unique_ptr<vector<char>> bytes) {
timeout_callback_.Cancel();
if (!success) {
switch (last_action_) {
case Action::READ_GIT_HASH:
......@@ -234,9 +236,6 @@ void BattOrAgent::OnMessageRead(bool success,
}
}
// Successfully read a message, cancel any timeouts.
timeout_callback_.Cancel();
switch (last_action_) {
case Action::READ_INIT_ACK:
if (!IsAckOfControlCommand(type, BATTOR_CONTROL_MESSAGE_TYPE_INIT,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment