From: Alex Sharov Date: Wed, 13 Jul 2022 10:03:42 +0000 (+0700) Subject: use RLock where can (#766) X-Git-Tag: v1.47.0~5 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=67b55c222b3305548c12478c7276356154034741;p=btrtrc.git use RLock where can (#766) --- diff --git a/client.go b/client.go index dd03f338..cbf074f7 100644 --- 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() }