fix crash on preload

This commit is contained in:
yourok
2018-10-04 21:33:32 +03:00
parent b376c50fcb
commit 5a30c8428b
2 changed files with 13 additions and 6 deletions

View File

@@ -81,6 +81,18 @@ func (b *BufferPool) ReleaseBuffer(index int) {
}
}
func (b *BufferPool) Used() map[int]struct{} {
used := make(map[int]struct{})
b.mu.Lock()
defer b.mu.Unlock()
for _, b := range b.buffs {
if b.used {
used[b.pieceId] = struct{}{}
}
}
return used
}
func (b *BufferPool) Len() int {
return b.frees
}