mirror of
https://github.com/sot-tech/mochi.git
synced 2026-07-17 05:38:11 -07:00
Purge peers that have not announced for twice the announce interval
This commit is contained in:
+1
-1
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user