2007-01-20 zzz

* Improve performance by not reading in the whole
      piece from disk for each request. A huge memory savings
      on 1MB torrents with many peers.
This commit is contained in:
zzz
2007-01-21 01:43:31 +00:00
committed by zzz
parent 8a87df605b
commit e6e6d6f4ee
2 changed files with 4 additions and 4 deletions

View File

@ -184,7 +184,7 @@ class PeerState
return;
}
byte[] pieceBytes = listener.gotRequest(peer, piece);
byte[] pieceBytes = listener.gotRequest(peer, piece, begin, length);
if (pieceBytes == null)
{
// XXX - Protocol error-> diconnect?
@ -194,7 +194,7 @@ class PeerState
}
// More sanity checks
if (begin >= pieceBytes.length || begin + length > pieceBytes.length)
if (length != pieceBytes.length)
{
// XXX - Protocol error-> disconnect?
if (_log.shouldLog(Log.WARN))