From 3d941cb2e8d2bbe3977864ea60ce1e192031d2e7 Mon Sep 17 00:00:00 2001 From: neokami Date: Fri, 17 Nov 2023 12:57:31 +0100 Subject: [PATCH] Stopping an actors children should happen in reverse of spawning order --- actor/actor_context.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/actor/actor_context.go b/actor/actor_context.go index 16babf19..8ff65551 100644 --- a/actor/actor_context.go +++ b/actor/actor_context.go @@ -644,9 +644,10 @@ func (ctx *actorContext) stopAllChildren() { return } - ctx.extras.children.ForEach(func(_ int, pid *PID) { - ctx.Stop(pid) - }) + var pids = ctx.extras.children.pids + for i := len(pids) - 1; i >= 0; i-- { + pids[i].sendSystemMessage(ctx.actorSystem, stopMessage) + } } func (ctx *actorContext) tryRestartOrTerminate() {