Purge peers that have not announced for twice the announce interval

This commit is contained in:
Justin Li
2014-07-16 19:38:51 -04:00
parent 7fe6dc3b4e
commit cd6204f13d
6 changed files with 97 additions and 4 deletions
+1 -1
View File
@@ -91,7 +91,7 @@ func (t *Tracker) ServeAnnounce(w http.ResponseWriter, r *http.Request, p httpro
if err != nil {
return http.StatusInternalServerError, err
}
} else if torrent.PeerCount() == 0 {
} else if t.cfg.PurgeInactiveTorrents && torrent.PeerCount() == 0 {
// Rather than deleting the torrent explicitly, let the tracker driver
// ensure there are no race conditions.
conn.PurgeInactiveTorrent(torrent.Infohash)
+7
View File
@@ -99,6 +99,13 @@ func Serve(cfg *config.Config) {
glog.Fatal("New: ", err)
}
go tracker.PurgeInactivePeers(
t.pool,
cfg.PurgeInactiveTorrents,
cfg.Announce.Duration*2,
cfg.Announce.Duration,
)
glog.V(0).Info("Starting on ", cfg.Addr)
graceful.Run(cfg.Addr, cfg.RequestTimeout.Duration, NewRouter(t, cfg))
}