From 174915206515f7be9f7e1eaaf2b56dd013725a33 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 22 Jan 2019 01:41:07 +0100 Subject: [PATCH] Reorder some code in dht announcer --- torrent.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/torrent.go b/torrent.go index 9edfdc8f..133918b2 100644 --- a/torrent.go +++ b/torrent.go @@ -1355,20 +1355,17 @@ func (t *Torrent) dhtAnnouncer(s *dht.Server) { cl := t.cl for { select { - case <-t.wantPeersEvent.LockedChan(cl.locker()): case <-t.closed.LockedChan(cl.locker()): return + case <-t.wantPeersEvent.LockedChan(cl.locker()): } + cl.lock() + t.numDHTAnnounces++ + cl.unlock() err := t.announceToDht(true, s) - func() { - cl.lock() - defer cl.unlock() - if err == nil { - t.numDHTAnnounces++ - } else { - t.logger.Printf("error announcing %q to DHT: %s", t, err) - } - }() + if err != nil { + t.logger.Printf("error announcing %q to DHT: %s", t, err) + } } } -- 2.48.1