]> Sergey Matveev's repositories - btrtrc.git/commitdiff
use RLock where can (#766)
authorAlex Sharov <AskAlexSharov@gmail.com>
Wed, 13 Jul 2022 10:03:42 +0000 (17:03 +0700)
committerGitHub <noreply@github.com>
Wed, 13 Jul 2022 10:03:42 +0000 (20:03 +1000)
client.go

index dd03f338e06c34ae3dde2a89652e5d55f01a0488..cbf074f733518d99c2a0b1b7d53abf800d53d963 100644 (file)
--- a/client.go
+++ b/client.go
@@ -572,8 +572,8 @@ func (cl *Client) incomingConnection(nc net.Conn) {
 
 // Returns a handle to the given torrent, if it's present in the client.
 func (cl *Client) Torrent(ih metainfo.Hash) (t *Torrent, ok bool) {
-       cl.lock()
-       defer cl.unlock()
+       cl.rLock()
+       defer cl.rUnlock()
        t, ok = cl.torrents[ih]
        return
 }
@@ -1402,8 +1402,8 @@ func (cl *Client) WaitAll() bool {
 
 // Returns handles to all the torrents loaded in the Client.
 func (cl *Client) Torrents() []*Torrent {
-       cl.lock()
-       defer cl.unlock()
+       cl.rLock()
+       defer cl.rUnlock()
        return cl.torrentsAsSlice()
 }