Change mutex logic

This commit is contained in:
mcrakhman 2022-10-11 11:15:46 +02:00 committed by Mikhail Iudin
parent 2e20380ecd
commit 1b5b461c9b
No known key found for this signature in database
GPG Key ID: FAAAA8BAABDFF1C0

View File

@ -123,11 +123,11 @@ func (t *treeStorage) Heads() ([]string, error) {
}
func (t *treeStorage) SetHeads(heads []string) (err error) {
t.headsMx.Lock()
defer t.headsMx.Unlock()
defer func() {
if err == nil {
t.headsMx.Lock()
t.heads = heads
t.headsMx.Unlock()
}
}()
payload := createHeadsPayload(heads)