fix buffering cache

This commit is contained in:
YouROK
2020-12-08 22:03:48 +03:00
parent 442c1fc27a
commit 212a60a893
12 changed files with 83 additions and 31 deletions

View File

@@ -166,6 +166,8 @@ func (t *Torrent) progressEvent() {
}
func (t *Torrent) updateRA() {
t.muTorrent.Lock()
defer t.muTorrent.Unlock()
if t.Torrent != nil && t.Torrent.Info() != nil {
pieceLen := t.Torrent.Info().PieceLength
adj := pieceLen * int64(t.Torrent.Stats().ActivePeers) / int64(1+t.cache.Readers())
@@ -175,7 +177,7 @@ func (t *Torrent) updateRA() {
case adj > pieceLen*4:
adj = pieceLen * 4
}
t.cache.AdjustRA(adj)
go t.cache.AdjustRA(adj)
}
}