#gpowerd - Use unique names for timers from precondition and validation
The existing timer names were constructed from the position of the timer in the condition, but this position may be the same in both the precondition and validation. This change makes the names unique across different conditions.
PiperOrigin-RevId: 842757982
Change-Id: I6785c65c3134b2229c950f37efc217fc4d04a9f5
diff --git a/action_context.cc b/action_context.cc
index ca50fdf..eb9b6b3 100644
--- a/action_context.cc
+++ b/action_context.cc
@@ -76,11 +76,12 @@
std::make_shared<StateUpdater<ActionStateLog>>(initial_state)) {}
absl::Status ActionContext::StartCheckingCondition(
- Condition& condition,
+ Condition& condition, absl::string_view condition_id,
absl::AnyInvocable<void(absl::Status, Condition::MatchList)> callback) {
absl::Status status = condition.WaitForMatch(
- execution_task_name(), manager_.system_state_updater(),
- manager_.global_system_state_updater(), std::move(callback));
+ absl::StrCat(execution_task_name(), ".", condition_id),
+ manager_.system_state_updater(), manager_.global_system_state_updater(),
+ std::move(callback));
if (!status.ok()) {
LOG(ERROR) << "Failed to wait for condition for "
<< flight_record().DebugString() << ": " << status;
@@ -299,7 +300,7 @@
absl::Status ActionContext::EnterStateCheckingPrecondition() {
return StartCheckingCondition(
- *precondition_,
+ *precondition_, "precondition",
absl::bind_front(&ActionContext::NextStatePreconditionMatched, this));
}
@@ -380,7 +381,7 @@
absl::Status ActionContext::EnterStateValidatingFinalState() {
return StartCheckingCondition(
- *validation_,
+ *validation_, "validation",
absl::bind_front(&ActionContext::NextStateValidationCompleted, this));
}
diff --git a/action_context.h b/action_context.h
index 06fa51a..30d8666 100644
--- a/action_context.h
+++ b/action_context.h
@@ -216,7 +216,7 @@
void RunAction() ABSL_LOCKS_EXCLUDED(mutex_);
absl::Status StartCheckingCondition(
- Condition& condition,
+ Condition& condition, absl::string_view condition_id,
absl::AnyInvocable<void(absl::Status, Condition::MatchList)> callback)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);