]> granicus.if.org Git - transmission/commitdiff
(trunk libT) move tr_lpdAnnounceMore() out of the announcer module
authorJordan Lee <jordan@transmissionbt.com>
Thu, 17 Mar 2011 12:45:29 +0000 (12:45 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Thu, 17 Mar 2011 12:45:29 +0000 (12:45 +0000)
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.

libtransmission/announcer.c
libtransmission/session.c
libtransmission/session.h

index 79520039387242e02e58b49ac7b0e87db3d4ccf9..eb6cab7e773e8c60db316d2cf6ef960173ad26eb 100644 (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;
index 02849f6d853dd8459ad81e257b2b2c847a9e01c6..4e89f30e291118572fc3de98c96c3f76726db30b 100644 (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 );
 
index f2d41539da3f59c76182320db670d192f1900c66..1ae01ee9ce2cab64f3f5472f7a2a784440906225 100644 (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;