Ignore:
Timestamp:
Oct 12, 2009, 11:16:51 PM (13 years ago)
Author:
charles
Message:

(trunk libT) #2498: DHT broken

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/announcer.c

    r9305 r9306  
    2424#include "publish.h"
    2525#include "session.h"
     26#include "tr-dht.h"
    2627#include "torrent.h"
    2728#include "utils.h"
     
    15661567    const tr_bool canAnnounce = announcer->announceSlotsAvailable > 0;
    15671568    const tr_bool canScrape = announcer->scrapeSlotsAvailable > 0;
     1569    tr_torrent * tor = NULL;
     1570    const time_t now = time( NULL );
    15681571
    15691572    if( announcer->announceSlotsAvailable > 0 )
     
    15711574        int i;
    15721575        int n;
    1573         const time_t now = time( NULL );
    1574         tr_torrent * tor = NULL;
    15751576        tr_ptrArray announceMe = TR_PTR_ARRAY_INIT;
    15761577        tr_ptrArray scrapeMe = TR_PTR_ARRAY_INIT;
     
    16151616        tr_ptrArrayDestruct( &scrapeMe, NULL );
    16161617        tr_ptrArrayDestruct( &announceMe, NULL );
     1618    }
     1619
     1620    tor = NULL;
     1621    while(( tor = tr_torrentNext( announcer->session, tor ))) {
     1622        if( tor->dhtAnnounceAt <= now ) {
     1623            int rc = 1;
     1624            if( tor->isRunning && tr_torrentAllowsDHT(tor) )
     1625                rc = tr_dhtAnnounce(tor, 1);
     1626            if(rc == 0)
     1627                /* The DHT is not ready yet.  Try again soon. */
     1628                tor->dhtAnnounceAt = now + 5 + tr_cryptoWeakRandInt( 5 );
     1629            else
     1630                /* We should announce at least once every 30 minutes. */
     1631                tor->dhtAnnounceAt = now + 25 * 60 + tr_cryptoWeakRandInt( 3 * 60 );
     1632        }
    16171633    }
    16181634}
Note: See TracChangeset for help on using the changeset viewer.