]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix missed unlock adding peers to non-existent torrent
authorMatt Joiner <anacrolix@gmail.com>
Tue, 22 Jul 2014 15:51:30 +0000 (01:51 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 22 Jul 2014 15:51:30 +0000 (01:51 +1000)
client.go

index 4a42b17c759af9884d634ec3ac0e8ab400801e4d..9463a8e1f570c156ee14b5663d2a227b7c2124b8 100644 (file)
--- a/client.go
+++ b/client.go
@@ -816,13 +816,13 @@ func (me *Client) openNewConns() {
 // Adds peers to the swarm for the torrent corresponding to infoHash.
 func (me *Client) AddPeers(infoHash InfoHash, peers []Peer) error {
        me.mu.Lock()
+       defer me.mu.Unlock()
        t := me.torrent(infoHash)
        if t == nil {
                return errors.New("no such torrent")
        }
        t.Peers = append(t.Peers, peers...)
        me.openNewConns()
-       me.mu.Unlock()
        return nil
 }