fix crash on preload

This commit is contained in:
yourok
2018-10-09 20:13:45 +03:00
parent 461b5e7004
commit 4afea294b8

View File

@@ -82,9 +82,12 @@ func (b *BufferPool) ReleaseBuffer(index int) {
}
func (b *BufferPool) Used() map[int]struct{} {
if len(b.buffs) == 0 {
b.mu.Lock()
b.mkBuffs()
b.mu.Unlock()
}
used := make(map[int]struct{})
b.mu.Lock()
defer b.mu.Unlock()
for _, b := range b.buffs {
if b.used {
used[b.pieceId] = struct{}{}