fix endgame bug reported again and again and again by SoftwareElves ;)

This commit is contained in:
Charles Kerr 2007-07-25 18:30:00 +00:00
parent d84c2bd44a
commit fd7c112151
1 changed files with 4 additions and 1 deletions

View File

@ -693,7 +693,7 @@ writeEnd:
const int n = TR_BLOCKS_IN_PIECE( tor, piece ); const int n = TR_BLOCKS_IN_PIECE( tor, piece );
const int end = firstBlock + n; const int end = firstBlock + n;
int block; int block;
for( block=firstBlock; block<end; ++block ) for( block=firstBlock; openSlots>0 && block<end; ++block )
{ {
/* don't ask for it if we've already got it */ /* don't ask for it if we've already got it */
if( tr_cpBlockIsComplete( tor->completion, block )) if( tr_cpBlockIsComplete( tor->completion, block ))
@ -716,6 +716,9 @@ writeEnd:
tr_free( pool ); tr_free( pool );
} }
assert( peer->inRequestCount <= peer->inRequestMax );
assert( peer->inRequestMax <= peer->inRequestAlloc );
return TR_OK; return TR_OK;
} }