mirror of
https://github.com/transmission/transmission.git
synced 2026-04-22 09:49:05 +01:00
a better fix for the tr_rand() crash experienced earlier today
This commit is contained in:
@@ -685,7 +685,7 @@ writeEnd:
|
||||
all peers for 2, and so on. Randomize our starting point
|
||||
into "pool" to reduce such overlap */
|
||||
int piecesLeft = poolSize;
|
||||
int p = (int)(tr_date() % poolSize);
|
||||
int p = piecesLeft ? tr_rand(piecesLeft) : 0;
|
||||
for( ; openSlots>0 && piecesLeft>0; --piecesLeft, p=(p+1)%poolSize )
|
||||
{
|
||||
const int piece = pool[p];
|
||||
|
||||
Reference in New Issue
Block a user