Changeset 3273


Ignore:
Timestamp:
Oct 2, 2007, 7:25:18 PM (14 years ago)
Author:
charles
Message:

make the peer manager a little greedier w.r.t. keeping connections alive.

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-mgr-private.h

    r3260 r3273  
    5050    char * client;
    5151
    52     time_t clientSentPieceDataAt;
    5352    time_t peerSentPieceDataAt;
    5453    time_t chokeChangedAt;
     54    time_t pieceDataActivityDate;
    5555
    5656    struct tr_peermsgs * msgs;
  • trunk/libtransmission/peer-mgr.c

    r3271 r3273  
    521521    managerLock( manager );
    522522
    523     /* free the torrents. */
    524     tr_ptrArrayFree( manager->torrents, (PtrArrayForeachFunc)torrentDestructor );
    525 
    526523    /* free the handshakes.  Abort invokes handshakeDoneCB(), which removes
    527524     * the item from manager->handshakes, so this is a little roundabout... */
     
    529526        tr_handshakeAbort( tr_ptrArrayNth( manager->incomingHandshakes, 0 ) );
    530527    tr_ptrArrayFree( manager->incomingHandshakes, NULL );
     528
     529    /* free the torrents. */
     530    tr_ptrArrayFree( manager->torrents, (PtrArrayForeachFunc)torrentDestructor );
    531531
    532532    managerUnlock( manager );
     
    14671467};
    14681468
    1469 #define LAISSEZ_FAIRE_PERIOD_SECS 60
     1469#define LAISSEZ_FAIRE_PERIOD_SECS 90
    14701470
    14711471static int
     
    15011501        assert( atom != NULL );
    15021502
    1503         if( peer->doPurge )
     1503        if( throughput >= 3 )
     1504            isWeak = FALSE;
     1505        else if( peer->doPurge )
    15041506            isWeak = TRUE;
    1505         if( peerIsSeed && clientIsSeed && (now-atom->time >= 30) ) /* pex time */
     1507        else if( peerIsSeed && clientIsSeed && (now-atom->time >= 30) ) /* pex time */
    15061508            isWeak = TRUE;
    15071509        else if( ( now - atom->time ) < LAISSEZ_FAIRE_PERIOD_SECS )
    15081510            isWeak = FALSE;
    1509         else if( throughput >= 5 )
    1510             isWeak = FALSE;
     1511#if 0
    15111512        else
    15121513            isWeak = TRUE;
     1514#else
     1515        else if( now - peer->pieceDataActivityDate > 180 )
     1516            isWeak = TRUE;
     1517        else
     1518            isWeak = FALSE;
     1519#endif
    15131520
    15141521        if( isWeak )
     
    16041611
    16051612        /* disconnect some peers */
    1606         for( i=0; i<nConnections && i<(peerCount-5); ++i ) {
     1613        for( i=0; i<nConnections && i<(peerCount-5) && i<MAX_RECONNECTIONS_PER_PULSE; ++i ) {
    16071614            const double throughput = connections[i].throughput;
    16081615            tr_peer * peer = connections[i].peer;
  • trunk/libtransmission/peer-msgs.c

    r3269 r3273  
    973973    tor->activityDate = tr_date( );
    974974    tor->downloadedCur += byteCount;
     975    msgs->info->pieceDataActivityDate = time( NULL );
    975976    tr_rcTransferred( msgs->info->rateToClient, byteCount );
    976977    tr_rcTransferred( tor->download, byteCount );
     
    984985    tor->activityDate = tr_date( );
    985986    tor->uploadedCur += byteCount;
     987    msgs->info->pieceDataActivityDate = time( NULL );
    986988    tr_rcTransferred( msgs->info->rateToPeer, byteCount );
    987989    tr_rcTransferred( tor->upload, byteCount );
Note: See TracChangeset for help on using the changeset viewer.