more no-readback fixes

This commit is contained in:
Arvid Norberg 2011-09-27 07:50:58 +00:00
parent d8641705e3
commit b3d2877274
1 changed files with 12 additions and 1 deletions

View File

@ -432,6 +432,7 @@ namespace libtorrent
int pos = 0;
int start = 0;
int blocks_in_piece = 0;
int first_block = -1;
if (avoid_readback)
{
// with the avoid read-back mode, only consider blocks
@ -446,7 +447,11 @@ namespace libtorrent
for (int i = 0; i < blocks_in_piece; ++i)
{
if (p.blocks[i].buf) ++current;
if (p.blocks[i].buf)
{
if (first_block == -1) first_block = i;
++current;
}
else
{
if (current > len)
@ -464,6 +469,12 @@ namespace libtorrent
pos = start;
}
if (avoid_readback && first_block >= 0 && p.next_block_to_hash - first_block > lower_limit)
{
len = flush_range(p, first_block, p.next_block_to_hash, l);
return len;
}
if (len < lower_limit || len <= 0) return 0;
len = flush_range(p, pos, pos + len, l);
return len;