don't try looking up boxes concurrently
Ted Unangst tedu@tedunangst.com
Tue, 16 Apr 2019 20:20:42 -0400
1 files changed,
12 insertions(+),
0 deletions(-)
jump to
M
activity.go
→
activity.go
@@ -273,6 +273,7 @@ }
var boxofboxes = make(map[string]*Box) var boxlock sync.Mutex +var boxinglock sync.Mutex func getboxes(ident string) (*Box, error) { boxlock.Lock()@@ -281,6 +282,17 @@ boxlock.Unlock()
if ok { return b, nil } + + boxinglock.Lock() + defer boxinglock.Unlock() + + boxlock.Lock() + b, ok = boxofboxes[ident] + boxlock.Unlock() + if ok { + return b, nil + } + j, err := GetJunk(ident) if err != nil { return nil, err