From 3dfe29724aec01d72ba771d3314ceaaeed8a19ac Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 16 Apr 2019 20:20:42 -0400 Subject: [PATCH] don't try looking up boxes concurrently --- activity.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/activity.go b/activity.go index 1a133df..3aa889d 100644 --- a/activity.go +++ b/activity.go @@ -273,6 +273,7 @@ type Box struct { 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 @@ func getboxes(ident string) (*Box, error) { 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