Handle tracker announce prepare errors

This commit is contained in:
Matt Joiner 2016-05-23 11:00:49 +10:00
parent c6ec935e53
commit b0923608bb
1 changed files with 7 additions and 3 deletions

View File

@ -30,12 +30,16 @@ func trackerToTorrentPeers(ps []tracker.Peer) (ret []Peer) {
return
}
// Return how long to wait before trying again.
// Return how long to wait before trying again. For most errors, we return 5
// minutes, a relatively quick turn around for DNS changes.
func (me *trackerScraper) announce() time.Duration {
blocked, urlToUse, host, err := me.t.cl.prepareTrackerAnnounceUnlocked(me.url)
if err != nil {
log.Printf("error preparing announce to %q: %s", me.url, err)
return 5 * time.Minute
}
if blocked {
// Wait for DNS to potentially change. Very few people do it faster
// than 5 minutes.
log.Printf("announce to tracker %q blocked by IP", me.url)
return 5 * time.Minute
}
me.t.cl.mu.Lock()