From 6cf281a3111f9ab9137d424adf3524929c24f917 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Tue, 15 Feb 2011 19:10:56 +0000 Subject: [PATCH] Make the initial DHT bootstrap more persistent. We now try to contact the bootstrap nodes up to six times. A better solution might be to reattempt bootstrap every half hour or so. This might be beneficial to people whose connectivity changes while Transmission is running. --- libtransmission/tr-dht.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/libtransmission/tr-dht.c b/libtransmission/tr-dht.c index 663c6ba5b..34840aeca 100644 --- a/libtransmission/tr-dht.c +++ b/libtransmission/tr-dht.c @@ -230,15 +230,21 @@ dht_bootstrap(void *closure) tr_free( bootstrap_file ); } - /* We really don't want to abuse our bootstrap nodes. - Be glacially slow. */ - if(!bootstrap_done(cl->session, 0)) - nap(30); - if(!bootstrap_done(cl->session, 0)) { - tr_ninf("DHT", "Attempting bootstrap from dht.transmissionbt.com"); - bootstrap_from_name( "dht.transmissionbt.com", 6881, - bootstrap_af(session) ); + for(i = 0; i < 6; i++) { + /* We don't want to abuse our bootstrap nodes, so be very + slow. The initial wait is to give other nodes a chance + to contact us before we attempt to contact a bootstrap + node, for example because we've just been restarted. */ + nap(40); + if(bootstrap_done(cl->session, 0)) + break; + if(i == 0) + tr_ninf("DHT", + "Attempting bootstrap from dht.transmissionbt.com"); + bootstrap_from_name( "dht.transmissionbt.com", 6881, + bootstrap_af(session) ); + } } if( cl->nodes ) -- 2.40.0