[#694] pkg/network: Use client cache in raw client getter
Every raw client getter invocation produced new connection, that lead to connection leak. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
53391f057e
commit
38afb82926
1 changed files with 7 additions and 2 deletions
9
pkg/network/cache/multi.go
vendored
9
pkg/network/cache/multi.go
vendored
|
@ -324,9 +324,14 @@ func (x *multiClient) Close() error {
|
|||
func (x *multiClient) RawForAddress(addr network.Address) *rawclient.Client {
|
||||
x.mtx.Lock()
|
||||
|
||||
c := x.createForAddress(addr).Raw()
|
||||
strAddr := addr.String()
|
||||
|
||||
c, cached := x.clients[strAddr]
|
||||
if !cached {
|
||||
c = x.createForAddress(addr)
|
||||
}
|
||||
|
||||
x.mtx.Unlock()
|
||||
|
||||
return c
|
||||
return c.Raw()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue