Fix locks around Torrent.announceRequest

This commit is contained in:
Matt Joiner 2020-04-13 19:13:59 +10:00
parent 05e448d132
commit f90cbcce20
2 changed files with 4 additions and 3 deletions

View File

@ -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",

View File

@ -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,