Changeset 10085
- Timestamp:
- Feb 3, 2010, 12:12:19 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-mgr.c
r10017 r10085 61 61 MAX_UPLOAD_IDLE_SECS = ( 60 * 5 ), 62 62 63 /* max # of peers to ask fer per torrent per reconnect pulse */64 MAX_RECONNECTIONS_PER_PULSE = 8,65 66 63 /* max number of peers to ask for per second overall. 67 64 * this throttle is to avoid overloading the router */ … … 2686 2683 } 2687 2684 2685 /* Make a lot of slots available to newly-running torrents... 2686 * once they reach steady state, they shouldn't need as many */ 2687 static int 2688 maxNewPeersPerPulse( const Torrent * t ) 2689 { 2690 double runTime; 2691 const tr_torrent * tor = t->tor; 2692 2693 assert( tr_isTorrent( tor ) ); 2694 2695 runTime = difftime( tr_time( ), tor->startDate ); 2696 if( runTime > 480 ) return 1; 2697 if( runTime > 240 ) return 2; 2698 if( runTime > 120 ) return 3; 2699 return 4; 2700 } 2701 2688 2702 static void 2689 2703 reconnectTorrent( Torrent * t ) … … 2709 2723 int maxCandidates; 2710 2724 struct tr_peer ** mustClose; 2725 const int maxPerPulse = maxNewPeersPerPulse( t ); 2711 2726 2712 2727 /* disconnect the really bad peers */ … … 2717 2732 2718 2733 /* decide how many peers can we try to add in this pass */ 2719 maxCandidates = MAX_RECONNECTIONS_PER_PULSE; 2734 2735 maxCandidates = maxPerPulse; 2720 2736 if( tr_announcerHasBacklog( t->manager->session->announcer ) ) 2721 2737 maxCandidates /= 2; … … 2731 2747 t->tor->info.name, mustCloseCount, 2732 2748 tr_ptrArraySize( &t->pool ), 2733 MAX_RECONNECTIONS_PER_PULSE);2734 2735 tordbg( t, "maxCandidates is %d, MAX_RECONNECTIONS_PER_PULSEis %d, "2749 maxPerPulse ); 2750 2751 tordbg( t, "maxCandidates is %d, maxPerPulse is %d, " 2736 2752 "getPeerCount(t) is %d, getMaxPeerCount(t) is %d, " 2737 2753 "newConnectionsThisSecond is %d, MAX_CONNECTIONS_PER_SECOND is %d", 2738 maxCandidates, MAX_RECONNECTIONS_PER_PULSE,2754 maxCandidates, maxPerPulse, 2739 2755 getPeerCount( t ), getMaxPeerCount( t->tor ), 2740 2756 newConnectionsThisSecond, MAX_CONNECTIONS_PER_SECOND ); … … 2763 2779 t->tor->info.name, mustCloseCount, 2764 2780 canCloseCount, candidateCount, 2765 tr_ptrArraySize( &t->pool ), MAX_RECONNECTIONS_PER_PULSE);2766 2767 tordbg( t, "candidateCount is %d, MAX_RECONNECTIONS_PER_PULSEis %d,"2781 tr_ptrArraySize( &t->pool ), maxPerPulse ); 2782 2783 tordbg( t, "candidateCount is %d, maxPerPulse is %d," 2768 2784 " getPeerCount(t) is %d, getMaxPeerCount(t) is %d, " 2769 2785 "newConnectionsThisSecond is %d, MAX_CONNECTIONS_PER_SECOND is %d", 2770 candidateCount, MAX_RECONNECTIONS_PER_PULSE,2786 candidateCount, maxPerPulse, 2771 2787 getPeerCount( t ), getMaxPeerCount( t->tor ), 2772 2788 newConnectionsThisSecond, MAX_CONNECTIONS_PER_SECOND );
Note: See TracChangeset
for help on using the changeset viewer.