From f90cbcce20a3a7ba47f1cef8ca47a88fb3ac54b5 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 13 Apr 2020 19:13:59 +1000 Subject: [PATCH] Fix locks around Torrent.announceRequest --- torrent.go | 3 ++- tracker_scraper.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/torrent.go b/torrent.go index 51a8cce5..c12d5211 100644 --- a/torrent.go +++ b/torrent.go @@ -1321,8 +1321,9 @@ func (t *Torrent) startScrapingTracker(_url string) { t.logger.WithText(func(m log.Msg) string { return fmt.Sprintf("%q: %v", u.String(), m.Text()) }).WithValues(log.Debug))} + ar := t.announceRequest(tracker.Started) go func() { - err := wst.TrackerClient.Run(t.announceRequest(tracker.Started), u.String()) + err := wst.TrackerClient.Run(ar, u.String()) if err != nil { t.logger.WithValues(log.Error).Printf( "error running websocket tracker announcer for %q: %v", diff --git a/tracker_scraper.go b/tracker_scraper.go index b664b2bf..c580afc9 100644 --- a/tracker_scraper.go +++ b/tracker_scraper.go @@ -113,9 +113,9 @@ func (me *trackerScraper) announce(event tracker.AnnounceEvent) (ret trackerAnno ret.Err = fmt.Errorf("error getting ip: %s", err) return } - me.t.cl.lock() + me.t.cl.rLock() req := me.t.announceRequest(event) - me.t.cl.unlock() + me.t.cl.rUnlock() //log.Printf("announcing %s %s to %q", me.t, req.Event, me.u.String()) res, err := tracker.Announce{ HTTPProxy: me.t.cl.config.HTTPProxy,