all repos — honk @ a7632cd00ab7b6e0885eef5b41b4a8bfb1c3f2fa

my fork of honk

don't cache box lookup failure. don't hold lock for too long.
Ted Unangst tedu@tedunangst.com
Sun, 14 Apr 2019 13:23:27 -0400
commit

a7632cd00ab7b6e0885eef5b41b4a8bfb1c3f2fa

parent

b6253de580f2b0f509290dd7205a90a690f6edaa

1 files changed, 3 insertions(+), 5 deletions(-)

jump to
M activity.goactivity.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 }