(trunk libT) #1829: high CPU use in refillPiece()

This commit is contained in:
Charles Kerr 2009-02-25 13:04:51 +00:00
parent 9cc421d6a2
commit 91940d1c07
1 changed files with 10 additions and 1 deletions

View File

@ -705,6 +705,12 @@ blockIteratorNext( struct tr_blockIterator * i, tr_block_index_t * setme )
return found;
}
static void
blockIteratorSkipCurrentPiece( struct tr_blockIterator * i )
{
i->blockIndex = i->blockCount;
}
static void
blockIteratorFree( struct tr_blockIterator ** inout )
{
@ -812,7 +818,7 @@ refillPulse( void * vtorrent )
&& (( hasNext = blockIteratorNext( t->refillQueue, &block ))) )
{
int j;
int handled = FALSE;
tr_bool handled = FALSE;
const tr_piece_index_t index = tr_torBlockPiece( tor, block );
const uint32_t offset = getBlockOffsetInPiece( tor, block );
@ -867,6 +873,9 @@ refillPulse( void * vtorrent )
break;
}
}
if( !handled )
blockIteratorSkipCurrentPiece( t->refillQueue );
}
/* cleanup */