Skip to content

Commit

Permalink
[sre] Ensure an agent killing in "on Initialize" has effects.
Browse files Browse the repository at this point in the history
close #864

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Sep 28, 2018
1 parent 658bd46 commit d44010c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Expand Up @@ -244,6 +244,9 @@ private void runInitializationStage(Event event) {
setOwnerState(OwnerState.ALIVE);
}
this.agentAsEventListener.fireEnqueuedEvents(this);
if (this.agentAsEventListener.isKilled.get()) {
this.agentAsEventListener.killOwner(InternalEventBusSkill.this);
}
} catch (Exception e) {
// Log the exception
final Logging loggingCapacity = getLoggingSkill();
Expand Down Expand Up @@ -344,7 +347,9 @@ private class AgentEventListener implements EventListener {

private final UUID aid;

private final AtomicBoolean isKilled = new AtomicBoolean(false);
/** Indicates if the agent has requested to be killed.
*/
final AtomicBoolean isKilled = new AtomicBoolean(false);

@SuppressWarnings("synthetic-access")
AgentEventListener() {
Expand Down Expand Up @@ -408,7 +413,7 @@ void fireEnqueuedEvents(InternalEventBusSkill skill) {
}

@SuppressWarnings("synthetic-access")
private boolean killOwner(InternalEventBusSkill skill) {
boolean killOwner(InternalEventBusSkill skill) {
return skill.spawnService.killAgent(this.aid);
}

Expand Down
Expand Up @@ -283,7 +283,8 @@ public boolean killAgent(UUID agentID) {
warningMessage = Messages.StandardSpawnService_7;
}
} else {
warningMessage = Messages.StandardSpawnService_8;
this.logger.getKernelLogger().finer(Messages.StandardSpawnService_8);
return false;
}
}

Expand Down

0 comments on commit d44010c

Please sign in to comment.