Skip to content

Commit

Permalink
Fix cleanup of children (#157)
Browse files Browse the repository at this point in the history
cleanupChildren
  • Loading branch information
tralafiti authored Jun 23, 2024
1 parent 18fd0e4 commit 46e6680
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion actor/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ func TestSpawnChildPID(t *testing.T) {

func TestChild(t *testing.T) {
var (
wg = sync.WaitGroup{}
wg = sync.WaitGroup{}
stopWg = sync.WaitGroup{}
)
e, err := NewEngine(NewEngineConfig())
require.NoError(t, err)
Expand All @@ -88,6 +89,9 @@ func TestChild(t *testing.T) {
c.SpawnChildFunc(func(_ *Context) {}, "child", WithID("3"))
case Started:
assert.Equal(t, 3, len(c.Children()))
c.Engine().Stop(c.Children()[0], &stopWg)
stopWg.Wait()
assert.Equal(t, 2, len(c.Children()))
wg.Done()
}
}, "foo", WithID("bar/baz"))
Expand Down
2 changes: 1 addition & 1 deletion actor/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (p *process) tryRestart(v any) {

func (p *process) cleanup(wg *sync.WaitGroup) {
if p.context.parentCtx != nil {
p.context.parentCtx.children.Delete(p.Kind)
p.context.parentCtx.children.Delete(p.pid.ID)
}

if p.context.children.Len() > 0 {
Expand Down

0 comments on commit 46e6680

Please sign in to comment.