Fixed bug in aos::starter::StarterClient::Succeed
To enable support for chaining commands with StarterClient,
it was necessary to change the order that StarterClient::Succeed
was performing its cleanup operations. With the new change,
a downstream function can call StarterClient.SetTimeoutHandler
inside their function that was set as the success callback.
A unit test was added to starter_test.cc to demonstrate that
this change fixes the issue.
Change-Id: I5de0ed99064b0d2550242cd3b3af80748fb25e6b
Signed-off-by: Maxwell Gumley <maxwell.gumley@bluerivertech.com>
Signed-off-by: Austin Schuh <austin.linux@bluerivertech.com>
diff --git a/aos/starter/starter_rpc_lib.cc b/aos/starter/starter_rpc_lib.cc
index 15132ec..5f14e21 100644
--- a/aos/starter/starter_rpc_lib.cc
+++ b/aos/starter/starter_rpc_lib.cc
@@ -225,10 +225,12 @@
// Clear commands prior to calling handlers to allow the handler to call
// SendCommands() again if desired.
current_commands_.clear();
+ // Clear the timer before calling success handler, in case the success
+ // handler needs to modify timeout handler.
+ timeout_timer_->Disable();
if (success_handler_) {
success_handler_();
}
- timeout_timer_->Disable();
}
bool SendCommandBlocking(aos::starter::Command command, std::string_view name,