use RLock where can (#766)

This commit is contained in:
Alex Sharov 2022-07-13 17:03:42 +07:00 committed by GitHub
parent a5877a938c
commit 67b55c222b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -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()
}