From 0a3059683bc7afc8629967088607f380f4ad7166 Mon Sep 17 00:00:00 2001 From: Raphael Vigee Date: Sun, 7 Apr 2024 22:01:39 +0100 Subject: [PATCH] fix race condition --- worker2/dep.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/worker2/dep.go b/worker2/dep.go index 9418821c..79672597 100644 --- a/worker2/dep.go +++ b/worker2/dep.go @@ -240,10 +240,19 @@ func (g *Group) LinkDeps() { } func (g *Group) GetDepsObj() *Deps { + if g.Deps != nil { + return g.Deps + } + + g.m.Lock() + defer g.m.Unlock() + if g.Deps == nil { - g.Deps = NewDeps() + d := NewDeps() + d.setOwner(g) + g.Deps = d } - g.Deps.setOwner(g) + return g.Deps }