(trunk libT) move tr_lpdAnnounceMore() out of the announcer module

We can stop local peer discovery immediately during shutdown, but need to leave the announcer running for the event=stopped messages. So it doesn't make sense to keep them on the same periodic timer.
This commit is contained in:
Jordan Lee 2011-03-17 12:45:29 +00:00
parent 6835374661
commit 501f2e106f
3 changed files with 11 additions and 12 deletions

View File

@ -28,7 +28,6 @@
#include "peer-mgr.h" /* tr_peerMgrCompactToPex() */
#include "ptrarray.h"
#include "session.h"
#include "tr-lpd.h"
#include "torrent.h"
#include "utils.h"
@ -63,9 +62,6 @@ enum
UPKEEP_INTERVAL_SECS = 1,
/* this is an upper limit for the frequency of LDS announces */
LPD_HOUSEKEEPING_INTERVAL_SECS = 5,
/* this is how often to call the UDP tracker upkeep */
TAU_UPKEEP_INTERVAL_SECS = 5
};
@ -1505,13 +1501,6 @@ onUpkeepTimer( int foo UNUSED, short bar UNUSED, void * vannouncer )
/* maybe send out some announcements to trackers */
announceMore( announcer );
/* LPD upkeep */
if( announcer->lpdUpkeepAt <= now ) {
const int seconds = LPD_HOUSEKEEPING_INTERVAL_SECS;
announcer->lpdUpkeepAt = now + jitterize( seconds );
tr_lpdAnnounceMore( now, seconds );
}
/* TAU upkeep */
if( announcer->tauUpkeepAt <= now ) {
announcer->tauUpkeepAt = now + TAU_UPKEEP_INTERVAL_SECS;

View File

@ -609,6 +609,7 @@ onNowTimer( int foo UNUSED, short bar UNUSED, void * vsession )
struct timeval tv;
tr_torrent * tor = NULL;
tr_session * session = vsession;
const time_t now = time( NULL );
assert( tr_isSession( session ) );
assert( session->nowTimer != NULL );
@ -617,10 +618,17 @@ onNowTimer( int foo UNUSED, short bar UNUSED, void * vsession )
*** tr_session things to do once per second
**/
tr_timeUpdate( time( NULL ) );
tr_timeUpdate( now );
tr_dhtUpkeep( session );
/* lpd upkeep */
if( session->lpdUpkeepAt <= now ) {
const int LPD_UPKEEP_INTERVAL_SECS = 5;
session->lpdUpkeepAt = now + LPD_UPKEEP_INTERVAL_SECS;
tr_lpdAnnounceMore( now, LPD_UPKEEP_INTERVAL_SECS );
}
if( session->turtle.isClockEnabled )
turtleCheckClock( session, &session->turtle );

View File

@ -142,6 +142,8 @@ struct tr_session
struct event *udp_event;
struct event *udp6_event;
time_t lpdUpkeepAt;
/* The open port on the local machine for incoming peer requests */
tr_port private_peer_port;