Changeset 12184 for trunk/libtransmission/announcer.c
- Timestamp:
- Mar 17, 2011, 6:51:31 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/announcer.c
r12182 r12184 125 125 int slotsAvailable; 126 126 int key; 127 time_t lpdUpkeepAt;128 127 time_t tauUpkeepAt; 129 128 } … … 134 133 { 135 134 return announcer->slotsAvailable < 1; 136 }137 138 static inline time_t139 jitterize( const int val )140 {141 const double jitter = 0.1;142 assert( val > 0 );143 return val + tr_cryptoWeakRandInt((int)(1 + val * jitter));144 135 } 145 136 … … 159 150 a->session = session; 160 151 a->slotsAvailable = MAX_CONCURRENT_TASKS; 161 a->lpdUpkeepAt = tr_time() + jitterize(5);162 152 a->upkeepTimer = evtimer_new( session->event_base, onUpkeepTimer, a ); 163 153 tr_timerAdd( a->upkeepTimer, UPKEEP_INTERVAL_SECS, 0 ); … … 174 164 175 165 flushCloseMessages( announcer ); 166 167 tr_tracker_udp_start_shutdown( session ); 176 168 177 169 event_free( announcer->upkeepTimer ); … … 1492 1484 onUpkeepTimer( int foo UNUSED, short bar UNUSED, void * vannouncer ) 1493 1485 { 1486 tr_announcer * announcer = vannouncer; 1487 tr_session * session = announcer->session; 1488 const tr_bool is_closing = session->isClosed; 1494 1489 const time_t now = tr_time( ); 1495 tr_announcer * announcer = vannouncer; 1496 tr_sessionLock( announcer->session );1490 1491 tr_sessionLock( session ); 1497 1492 1498 1493 /* maybe send out some "stopped" messages for closed torrents */ … … 1500 1495 1501 1496 /* maybe send out some announcements to trackers */ 1502 announceMore( announcer ); 1497 if( !is_closing ) 1498 announceMore( announcer ); 1503 1499 1504 1500 /* TAU upkeep */ 1505 1501 if( announcer->tauUpkeepAt <= now ) { 1506 1502 announcer->tauUpkeepAt = now + TAU_UPKEEP_INTERVAL_SECS; 1507 tr_tracker_udp_upkeep( announcer->session );1503 tr_tracker_udp_upkeep( session ); 1508 1504 } 1509 1505 … … 1511 1507 tr_timerAdd( announcer->upkeepTimer, UPKEEP_INTERVAL_SECS, 0 ); 1512 1508 1513 tr_sessionUnlock( announcer->session );1509 tr_sessionUnlock( session ); 1514 1510 } 1515 1511
Note: See TracChangeset
for help on using the changeset viewer.