Skip to content

Commit 50cf2cd

Browse files
knopers8teo
authored andcommitted
[occ] do not call iterateCheck when in ERROR
There is no point in asking the controlled task for a health check if it's still in ERROR. The task can go to healthy state by requesting a recover transition, which gives a success or failure as a return value. OCTRL-958
1 parent de4d866 commit 50cf2cd

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

occ/occlib/OccServer.cxx

+13-11
Original file line numberDiff line numberDiff line change
@@ -437,17 +437,19 @@ void OccServer::runChecker()
437437
}
438438
}
439439

440-
// execute periodic check, in any state
441-
int err = m_rco->iterateCheck();
442-
// if there's an error but the SM hasn't been moved to t_State::error yet
443-
if (err && (m_rco->getState() != t_State::error)) {
444-
updateState(t_State::error);
445-
446-
// the above publishes a state change event to the StateStream, but we also push an exception event on the
447-
// EventStream because the transition was initiated by the task
448-
auto taskErrorEvent = new pb::DeviceEvent;
449-
taskErrorEvent->set_type(pb::TASK_INTERNAL_ERROR);
450-
pushEvent(taskErrorEvent);
440+
// execute periodic check, in any state except ERROR
441+
if (m_rco->getState() != t_State::error) {
442+
int err = m_rco->iterateCheck();
443+
// if there's an error but the SM hasn't been moved to t_State::error yet
444+
if (err) {
445+
updateState(t_State::error);
446+
447+
// the above publishes a state change event to the StateStream, but we also push an exception event on the
448+
// EventStream because the transition was initiated by the task
449+
auto taskErrorEvent = new pb::DeviceEvent;
450+
taskErrorEvent->set_type(pb::TASK_INTERNAL_ERROR);
451+
pushEvent(taskErrorEvent);
452+
}
451453
}
452454

453455
m_mu.unlock();

occ/occlib/RuntimeControlledObject.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@ class OCC_EXPORT RuntimeControlledObject {
268268
virtual int iterateRunning();
269269

270270
/**
271-
* Perform periodic checks during every state.
271+
* Perform periodic checks during every state except ERROR.
272272
*
273273
* @return 0 if the check completed successfully and the machine can stay in the current state,
274274
* or any other value to immediately trigger a transition to the error state.
275275
*
276-
* This function is called continuously by OccServer::runChecker in any state, including
276+
* This function is called continuously by OccServer::runChecker in any state except ERROR, including
277277
* t_State::running. Its purpose is for the implementer to report an unusual condition in
278278
* order to trigger a transition to t_State::error.
279279
*/

0 commit comments

Comments
 (0)