🎨 块树并发访问异常

This commit is contained in:
Liang Ding 2022-12-24 10:51:02 +08:00
parent a76cfb442c
commit 471089b6e9
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -59,6 +59,9 @@ func GetBlockTreeByPath(path string) *BlockTree {
}
func CountTrees() (ret int) {
blockTreesLock.Lock()
defer blockTreesLock.Unlock()
roots := map[string]bool{}
for _, b := range blockTrees {
roots[b.RootID] = true
@ -68,6 +71,8 @@ func CountTrees() (ret int) {
}
func CountBlocks() (ret int) {
blockTreesLock.Lock()
defer blockTreesLock.Unlock()
return len(blockTrees)
}