]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Set tracker announce numWant to 0 if we're unable to dial
authorMatt Joiner <anacrolix@gmail.com>
Thu, 16 Apr 2020 02:02:34 +0000 (12:02 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 16 Apr 2020 02:02:34 +0000 (12:02 +1000)
torrent.go
tracker_scraper.go

index 872c9102e40a94908628cc0b3c0d1b70e9495d78..ba94d8057504529be0dcc1a0b404b54d1b902675 100644 (file)
@@ -1379,11 +1379,17 @@ func (t *Torrent) startMissingTrackerScrapers() {
 // Returns an AnnounceRequest with fields filled out to defaults and current
 // values.
 func (t *Torrent) announceRequest(event tracker.AnnounceEvent) tracker.AnnounceRequest {
-       // Note that IPAddress is not set. It's set for UDP inside the tracker
-       // code, since it's dependent on the network in use.
+       // Note that IPAddress is not set. It's set for UDP inside the tracker code, since it's
+       // dependent on the network in use.
        return tracker.AnnounceRequest{
-               Event:    event,
-               NumWant:  -1,
+               Event: event,
+               NumWant: func() int32 {
+                       if t.wantPeers() && len(t.cl.dialers) > 0 {
+                               return -1
+                       } else {
+                               return 0
+                       }
+               }(),
                Port:     uint16(t.cl.incomingPeerPort()),
                PeerId:   t.cl.peerID,
                InfoHash: t.infoHash,
index 86d45c8ff51d7f175f4e4047f94a53333b5cd166..50b582c2bebb4fd4f25bd8e20a24c4c7c0103b81 100644 (file)
@@ -116,7 +116,7 @@ func (me *trackerScraper) announce(event tracker.AnnounceEvent) (ret trackerAnno
        me.t.cl.rLock()
        req := me.t.announceRequest(event)
        me.t.cl.rUnlock()
-       //log.Printf("announcing %s %s to %q", me.t, req.Event, me.u.String())
+       me.t.logger.Printf("announcing to %q: %#v", me.u.String(), req)
        res, err := tracker.Announce{
                HTTPProxy:  me.t.cl.config.HTTPProxy,
                UserAgent:  me.t.cl.config.HTTPUserAgent,