Ignore:
Timestamp:
Mar 17, 2011, 12:34:43 PM (11 years ago)
Author:
jordan
Message:

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

During shutdown, we can stop DHT almost immediately, but need to leave the announcer running for the DHT tracker event=stopped messages. So it doesn't make sense to keep them on the same periodic timer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/announcer.c

    r12177 r12181  
    2929#include "ptrarray.h"
    3030#include "session.h"
    31 #include "tr-dht.h"
    3231#include "tr-lpd.h"
    3332#include "torrent.h"
     
    14951494
    14961495static void
    1497 dht_upkeep( tr_session * session )
    1498 {
    1499     tr_torrent * tor = NULL;
    1500     const time_t now = tr_time( );
    1501 
    1502     while(( tor = tr_torrentNext( session, tor )))
    1503     {
    1504         if( tor->dhtAnnounceAt <= now )
    1505         {
    1506             if( tor->isRunning && tr_torrentAllowsDHT(tor) ) {
    1507                 const int rc = tr_dhtAnnounce(tor, AF_INET, 1);
    1508                 if(rc == 0)
    1509                     /* The DHT is not ready yet. Try again soon. */
    1510                     tor->dhtAnnounceAt = now + 5 + tr_cryptoWeakRandInt( 5 );
    1511                 else
    1512                     /* We should announce at least once every 30 minutes. */
    1513                     tor->dhtAnnounceAt =
    1514                         now + 25 * 60 + tr_cryptoWeakRandInt( 3 * 60 );
    1515             }
    1516         }
    1517 
    1518         if( tor->dhtAnnounce6At <= now )
    1519         {
    1520             if( tor->isRunning && tr_torrentAllowsDHT(tor) ) {
    1521                 const int rc = tr_dhtAnnounce(tor, AF_INET6, 1);
    1522                 if(rc == 0)
    1523                     tor->dhtAnnounce6At = now + 5 + tr_cryptoWeakRandInt( 5 );
    1524                 else
    1525                     tor->dhtAnnounce6At =
    1526                         now + 25 * 60 + tr_cryptoWeakRandInt( 3 * 60 );
    1527             }
    1528         }
    1529     }
    1530 }
    1531 
    1532 static void
    15331496onUpkeepTimer( int foo UNUSED, short bar UNUSED, void * vannouncer )
    15341497{
     
    15421505    /* maybe send out some announcements to trackers */
    15431506    announceMore( announcer );
    1544 
    1545     dht_upkeep( announcer->session );
    15461507
    15471508    /* LPD upkeep */
Note: See TracChangeset for help on using the changeset viewer.