Change mutex logic

This commit is contained in:
mcrakhman 2022-10-11 11:15:46 +02:00
parent 03eb8834c1
commit 46f562e91d
No known key found for this signature in database
GPG Key ID: DED12CFEF5B8396B

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)