Make the initial DHT bootstrap more persistent.
authorJuliusz Chroboczek <jch@pps.univ-paris-diderot.fr>
Tue, 15 Feb 2011 19:10:56 +0000 (19:10 +0000)
committerJuliusz Chroboczek <jch@pps.univ-paris-diderot.fr>
Tue, 15 Feb 2011 19:10:56 +0000 (19:10 +0000)
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

index 663c6ba5b5c5630d0236e74ce400ddb9aa944f58..34840aeca570f67a1bb1fdb80ad1aa6578eaf9dc 100644 (file)
@@ -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 )