Changeset 12421 for trunk/libtransmission/peer-mgr.c
- Timestamp:
- May 10, 2011, 1:51:12 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-mgr.c
r12402 r12421 3809 3809 getPeerCandidates( tr_session * session, int * candidateCount ) 3810 3810 { 3811 int n; 3811 int atomCount; 3812 int peerCount; 3812 3813 tr_torrent * tor; 3813 3814 struct peer_candidate * candidates; … … 3818 3819 const int maxCandidates = tr_sessionGetPeerLimit( session ) * 0.95; 3819 3820 3821 /* count how many peers and atoms we've got */ 3822 tor= NULL; 3823 atomCount = 0; 3824 peerCount = 0; 3825 while(( tor = tr_torrentNext( session, tor ))) { 3826 atomCount += tr_ptrArraySize( &tor->torrentPeers->pool ); 3827 peerCount += tr_ptrArraySize( &tor->torrentPeers->peers ); 3828 } 3829 3820 3830 /* don't start any new handshakes if we're full up */ 3821 n = 0; 3822 tor= NULL; 3823 while(( tor = tr_torrentNext( session, tor ))) 3824 n += tr_ptrArraySize( &tor->torrentPeers->peers ); 3825 if( maxCandidates <= n ) { 3831 if( maxCandidates <= peerCount ) { 3826 3832 *candidateCount = 0; 3827 3833 return NULL; … … 3829 3835 3830 3836 /* allocate an array of candidates */ 3831 n = 0; 3832 tor= NULL; 3833 while(( tor = tr_torrentNext( session, tor ))) 3834 n += tr_ptrArraySize( &tor->torrentPeers->pool ); 3835 walk = candidates = tr_new( struct peer_candidate, n ); 3837 walk = candidates = tr_new( struct peer_candidate, atomCount ); 3836 3838 3837 3839 /* populate the candidate array */
Note: See TracChangeset
for help on using the changeset viewer.