don't cache box lookup failure. don't hold lock for too long.
This commit is contained in:
parent
a80a156718
commit
2436a76b7e
|
@ -263,23 +263,21 @@ var boxlock sync.Mutex
|
||||||
|
|
||||||
func getboxes(ident string) (string, string, error) {
|
func getboxes(ident string) (string, string, error) {
|
||||||
boxlock.Lock()
|
boxlock.Lock()
|
||||||
defer boxlock.Unlock()
|
|
||||||
b, ok := boxofboxes[ident]
|
b, ok := boxofboxes[ident]
|
||||||
|
boxlock.Unlock()
|
||||||
if ok {
|
if ok {
|
||||||
if b == "" {
|
|
||||||
return "", "", fmt.Errorf("error?")
|
|
||||||
}
|
|
||||||
m := strings.Split(b, "\n")
|
m := strings.Split(b, "\n")
|
||||||
return m[0], m[1], nil
|
return m[0], m[1], nil
|
||||||
}
|
}
|
||||||
j, err := GetJunk(ident)
|
j, err := GetJunk(ident)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
boxofboxes[ident] = ""
|
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
inbox, _ := jsongetstring(j, "inbox")
|
inbox, _ := jsongetstring(j, "inbox")
|
||||||
outbox, _ := jsongetstring(j, "outbox")
|
outbox, _ := jsongetstring(j, "outbox")
|
||||||
|
boxlock.Lock()
|
||||||
boxofboxes[ident] = inbox + "\n" + outbox
|
boxofboxes[ident] = inbox + "\n" + outbox
|
||||||
|
boxlock.Unlock()
|
||||||
return inbox, outbox, err
|
return inbox, outbox, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue