mirror of
https://github.com/transmission/transmission
synced 2024-12-25 09:13:06 +00:00
(trunk libT) heap and event pruning: don't create evtimers for periodic pex messages if the torrent doesn't allow pex (such as, if it's on a private tracker).
Previously, we unconditionally created the evtimer, and then checked each time to see if pex was allowed.
This commit is contained in:
parent
244bd7bc1c
commit
294c2d7113
1 changed files with 8 additions and 3 deletions
|
@ -2309,6 +2309,7 @@ pexPulse( int foo UNUSED, short bar UNUSED, void * vmsgs )
|
|||
|
||||
sendPex( msgs );
|
||||
|
||||
assert( msgs->pexTimer != NULL );
|
||||
tr_timerAdd( msgs->pexTimer, PEX_INTERVAL_SECS, 0 );
|
||||
}
|
||||
|
||||
|
@ -2341,9 +2342,12 @@ tr_peerMsgsNew( struct tr_torrent * torrent,
|
|||
m->outMessagesBatchedAt = 0;
|
||||
m->outMessagesBatchPeriod = LOW_PRIORITY_INTERVAL_SECS;
|
||||
m->incoming.block = evbuffer_new( );
|
||||
m->pexTimer = evtimer_new( torrent->session->event_base, pexPulse, m );
|
||||
peer->msgs = m;
|
||||
tr_timerAdd( m->pexTimer, PEX_INTERVAL_SECS, 0 );
|
||||
|
||||
if( tr_torrentAllowsPex( torrent ) ) {
|
||||
m->pexTimer = evtimer_new( torrent->session->event_base, pexPulse, m );
|
||||
tr_timerAdd( m->pexTimer, PEX_INTERVAL_SECS, 0 );
|
||||
}
|
||||
|
||||
if( tr_peerIoSupportsUTP( peer->io ) ) {
|
||||
const tr_address * addr = tr_peerIoGetAddress( peer->io, NULL );
|
||||
|
@ -2376,7 +2380,8 @@ tr_peerMsgsFree( tr_peermsgs* msgs )
|
|||
{
|
||||
if( msgs )
|
||||
{
|
||||
event_free( msgs->pexTimer );
|
||||
if( msgs->pexTimer != NULL )
|
||||
event_free( msgs->pexTimer );
|
||||
|
||||
evbuffer_free( msgs->incoming.block );
|
||||
evbuffer_free( msgs->outMessages );
|
||||
|
|
Loading…
Reference in a new issue