From 2436a76b7e6c58155f7618da85c4ec74d2a1b0a4 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sun, 14 Apr 2019 13:23:27 -0400 Subject: [PATCH] don't cache box lookup failure. don't hold lock for too long. --- activity.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/activity.go b/activity.go index 4e4862f..b5248d6 100644 --- a/activity.go +++ b/activity.go @@ -263,23 +263,21 @@ var boxlock sync.Mutex func getboxes(ident string) (string, string, error) { boxlock.Lock() - defer boxlock.Unlock() b, ok := boxofboxes[ident] + boxlock.Unlock() if ok { - if b == "" { - return "", "", fmt.Errorf("error?") - } m := strings.Split(b, "\n") return m[0], m[1], nil } j, err := GetJunk(ident) if err != nil { - boxofboxes[ident] = "" return "", "", err } inbox, _ := jsongetstring(j, "inbox") outbox, _ := jsongetstring(j, "outbox") + boxlock.Lock() boxofboxes[ident] = inbox + "\n" + outbox + boxlock.Unlock() return inbox, outbox, err }