Changeset 8394


Ignore:
Timestamp:
May 13, 2009, 8:54:35 PM (12 years ago)
Author:
charles
Message:

(trunk libT) #2035: Transmission causes wakeups by unnecessary polling

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-mgr.c

    r8375 r8394  
    5454
    5555    /* how frequently to age out old piece request lists */
    56     REFILL_UPKEEP_PERIOD_MSEC = 10000,
     56    REFILL_UPKEEP_PERIOD_MSEC = ( 10 * 1000 ),
    5757
    5858    /* how frequently to decide which peers live and die */
     
    451451{
    452452    tr_peerMgr * m = tr_new0( tr_peerMgr, 1 );
    453 
    454453    m->session = session;
    455454    m->incomingHandshakes = TR_PTR_ARRAY_INIT;
    456     m->bandwidthTimer    = tr_timerNew( session, bandwidthPulse, m, BANDWIDTH_PERIOD_MSEC );
    457     m->rechokeTimer      = tr_timerNew( session, rechokePulse,   m, RECHOKE_PERIOD_MSEC );
    458     m->reconnectTimer    = tr_timerNew( session, reconnectPulse, m, RECONNECT_PERIOD_MSEC );
    459     m->refillUpkeepTimer = tr_timerNew( session, refillUpkeep,   m, REFILL_UPKEEP_PERIOD_MSEC );
    460 
    461     rechokePulse( m );
    462 
    463455    return m;
     456}
     457
     458static void
     459deleteTimers( struct tr_peerMgr * m )
     460{
     461    if( m->bandwidthTimer )
     462        tr_timerFree( &m->bandwidthTimer );
     463
     464    if( m->rechokeTimer == NULL )
     465        tr_timerFree( &m->rechokeTimer );
     466
     467    if( m->reconnectTimer == NULL )
     468        tr_timerFree( &m->reconnectTimer );
     469
     470    if( m->refillUpkeepTimer == NULL )
     471        tr_timerFree( &m->refillUpkeepTimer );
    464472}
    465473
     
    469477    managerLock( manager );
    470478
    471     tr_timerFree( &manager->refillUpkeepTimer );
    472     tr_timerFree( &manager->reconnectTimer );
    473     tr_timerFree( &manager->rechokeTimer );
    474     tr_timerFree( &manager->bandwidthTimer );
     479    deleteTimers( manager );
    475480
    476481    /* free the handshakes.  Abort invokes handshakeDoneCB(), which removes
     
    15691574}
    15701575
     1576static void
     1577ensureMgrTimersExist( struct tr_peerMgr * m )
     1578{
     1579    tr_session * s = m->session;
     1580
     1581    if( m->bandwidthTimer == NULL )
     1582        m->bandwidthTimer = tr_timerNew( s, bandwidthPulse, m, BANDWIDTH_PERIOD_MSEC );
     1583
     1584    if( m->rechokeTimer == NULL )
     1585        m->rechokeTimer = tr_timerNew( s, rechokePulse, m, RECHOKE_PERIOD_MSEC );
     1586
     1587    if( m->reconnectTimer == NULL )
     1588        m->reconnectTimer = tr_timerNew( s, reconnectPulse, m, RECONNECT_PERIOD_MSEC );
     1589
     1590    if( m->refillUpkeepTimer == NULL )
     1591        m->refillUpkeepTimer = tr_timerNew( s, refillUpkeep, m, REFILL_UPKEEP_PERIOD_MSEC );
     1592}
     1593
    15711594void
    15721595tr_peerMgrStartTorrent( tr_torrent * tor )
     
    15741597    Torrent * t = tor->torrentPeers;
    15751598
     1599    assert( t != NULL );
    15761600    managerLock( t->manager );
    1577 
    1578     assert( t );
     1601    ensureMgrTimersExist( t->manager );
    15791602
    15801603    if( !t->isRunning )
     
    15861609    }
    15871610
     1611    rechokePulse( t->manager );
    15881612    managerUnlock( t->manager );
    15891613}
  • trunk/libtransmission/tracker.c

    r8268 r8394  
    4242
    4343    /* seconds between tracker pulses */
    44     PULSE_INTERVAL_MSEC = 1000,
     44    PULSE_INTERVAL_MSEC = 1500,
    4545
    4646    /* unless the tracker says otherwise, rescrape this frequently */
Note: See TracChangeset for help on using the changeset viewer.