Ignore:
Timestamp:
Mar 17, 2011, 6:51:31 PM (11 years ago)
Author:
jordan
Message:

(trunk libT) better shutdown management of libutp and UDP trackers in tr_sessionClose().

This is a little overlapping since the utp code can be closed more-or-less immediately, but the udp manager needs to stay open in order to process the udp tracker connection requests before sending out event=stopped. Moreover DNS resolver can be shut down after the UDP tracker is shutdown.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/announcer.c

    r12182 r12184  
    125125    int slotsAvailable;
    126126    int key;
    127     time_t lpdUpkeepAt;
    128127    time_t tauUpkeepAt;
    129128}
     
    134133{
    135134    return announcer->slotsAvailable < 1;
    136 }
    137 
    138 static inline time_t
    139 jitterize( const int val )
    140 {
    141     const double jitter = 0.1;
    142     assert( val > 0 );
    143     return val + tr_cryptoWeakRandInt((int)(1 + val * jitter));
    144135}
    145136
     
    159150    a->session = session;
    160151    a->slotsAvailable = MAX_CONCURRENT_TASKS;
    161     a->lpdUpkeepAt = tr_time() + jitterize(5);
    162152    a->upkeepTimer = evtimer_new( session->event_base, onUpkeepTimer, a );
    163153    tr_timerAdd( a->upkeepTimer, UPKEEP_INTERVAL_SECS, 0 );
     
    174164
    175165    flushCloseMessages( announcer );
     166
     167    tr_tracker_udp_start_shutdown( session );
    176168
    177169    event_free( announcer->upkeepTimer );
     
    14921484onUpkeepTimer( int foo UNUSED, short bar UNUSED, void * vannouncer )
    14931485{
     1486    tr_announcer * announcer = vannouncer;
     1487    tr_session * session = announcer->session;
     1488    const tr_bool is_closing = session->isClosed;
    14941489    const time_t now = tr_time( );
    1495     tr_announcer * announcer = vannouncer;
    1496     tr_sessionLock( announcer->session );
     1490
     1491    tr_sessionLock( session );
    14971492
    14981493    /* maybe send out some "stopped" messages for closed torrents */
     
    15001495
    15011496    /* maybe send out some announcements to trackers */
    1502     announceMore( announcer );
     1497    if( !is_closing )
     1498        announceMore( announcer );
    15031499
    15041500    /* TAU upkeep */
    15051501    if( announcer->tauUpkeepAt <= now ) {
    15061502        announcer->tauUpkeepAt = now + TAU_UPKEEP_INTERVAL_SECS;
    1507         tr_tracker_udp_upkeep( announcer->session );
     1503        tr_tracker_udp_upkeep( session );
    15081504    }
    15091505
     
    15111507    tr_timerAdd( announcer->upkeepTimer, UPKEEP_INTERVAL_SECS, 0 );
    15121508
    1513     tr_sessionUnlock( announcer->session );
     1509    tr_sessionUnlock( session );
    15141510}
    15151511
Note: See TracChangeset for help on using the changeset viewer.