diff --git a/commonspace/object/tree/synctree/treestats.go b/commonspace/object/tree/synctree/treestats.go index 7effb3d2..9655f13b 100644 --- a/commonspace/object/tree/synctree/treestats.go +++ b/commonspace/object/tree/synctree/treestats.go @@ -25,9 +25,13 @@ func (t *TreeStatsCollector) Register(tree *syncTree) { func (t *TreeStatsCollector) Collect() []TreeStats { t.mutex.Lock() - defer t.mutex.Unlock() - stats := make([]TreeStats, 0, len(t.trees)) + trees := make([]*syncTree, 0, len(t.trees)) for _, tree := range t.trees { + trees = append(trees, tree) + } + t.mutex.Unlock() + stats := make([]TreeStats, 0, len(t.trees)) + for _, tree := range trees { tree.Lock() stats = append(stats, TreeStats{ TreeLen: tree.Len(),