Changeset 10820
- Timestamp:
- Jun 22, 2010, 4:31:38 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-mgr.c
r10800 r10820 2499 2499 * untested peers, and "bad" (ones with a high cancel-to-block ratio). 2500 2500 * That's the order in which we'll choose who to show interest in */ 2501 for( i=0; i<peerCount; ++i ) 2502 { 2503 tr_peer * peer = tr_ptrArrayNth( &t->peers, i ); 2504 2505 if( !isPeerInteresting( t->tor, peer ) ) 2501 { 2502 /* Randomize the peer array so the peers in the three groups will be unsorted... */ 2503 int n = peerCount; 2504 tr_peer ** peers = tr_memdup( tr_ptrArrayBase( &t->peers ), n * sizeof( tr_peer * ) ); 2505 2506 while( n > 0 ) 2506 2507 { 2507 tr_peerMsgsSetInterested( peer->msgs, FALSE ); 2508 } 2509 else 2510 { 2511 const int blocks = tr_historyGet( peer->blocksSentToClient, now, msec ); 2512 const int cancels = tr_historyGet( peer->cancelsSentToPeer, now, msec ); 2513 2514 if( !blocks && !cancels ) 2515 untested[untestedCount++] = peer; 2516 else if( !cancels ) 2517 good[goodCount++] = peer; 2518 else if( !blocks ) 2519 bad[badCount++] = peer; 2520 else if( ( cancels * 10 ) < blocks ) 2521 good[goodCount++] = peer; 2508 const int i = tr_cryptoWeakRandInt( n ); 2509 tr_peer * peer = tr_ptrArrayNth( &t->peers, i ); 2510 2511 if( !isPeerInteresting( t->tor, peer ) ) 2512 { 2513 tr_peerMsgsSetInterested( peer->msgs, FALSE ); 2514 } 2522 2515 else 2523 bad[badCount++] = peer; 2524 } 2516 { 2517 const int blocks = tr_historyGet( peer->blocksSentToClient, now, msec ); 2518 const int cancels = tr_historyGet( peer->cancelsSentToPeer, now, msec ); 2519 2520 if( !blocks && !cancels ) 2521 untested[untestedCount++] = peer; 2522 else if( !cancels ) 2523 good[goodCount++] = peer; 2524 else if( !blocks ) 2525 bad[badCount++] = peer; 2526 else if( ( cancels * 10 ) < blocks ) 2527 good[goodCount++] = peer; 2528 else 2529 bad[badCount++] = peer; 2530 } 2531 2532 tr_removeElementFromArray( peers, i, sizeof(tr_peer*), n-- ); 2533 } 2534 2535 tr_free( peers ); 2525 2536 } 2526 2537
Note: See TracChangeset
for help on using the changeset viewer.