]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix deadlock in Client.onDHTAnnouncePeer
authorMatt Joiner <anacrolix@gmail.com>
Sun, 27 Nov 2016 03:43:21 +0000 (14:43 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 27 Nov 2016 03:43:21 +0000 (14:43 +1100)
client.go

index 5dfb465efc72e5c91f3fb4c4173ad3b9d76fe749..b12dbf693e19d0cc723381034e5c52b97c85a30a 100644 (file)
--- a/client.go
+++ b/client.go
@@ -1358,8 +1358,8 @@ func (cl *Client) newConnection(nc net.Conn) (c *connection) {
 func (cl *Client) onDHTAnnouncePeer(ih metainfo.Hash, p dht.Peer) {
        cl.mu.Lock()
        defer cl.mu.Unlock()
-       t, ok := cl.Torrent(ih)
-       if !ok {
+       t := cl.torrent(ih)
+       if t == nil {
                return
        }
        t.addPeers([]Peer{{