From c09ee3241377aae2530a73d48c4e20641d76d0ee Mon Sep 17 00:00:00 2001 From: mhalaj1 Date: Thu, 26 Aug 2021 20:15:08 +0200 Subject: Refactoring and fixes * refactor creation of new channel * add missing closing of created streams * correct documentation regarding thread safety of stream Signed-off-by: mhalaj1 Change-Id: Ic601efff298fcbdecaafab83fa236253af69de21 --- core/connection.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'core/connection.go') diff --git a/core/connection.go b/core/connection.go index ee5a06b..935693e 100644 --- a/core/connection.go +++ b/core/connection.go @@ -245,14 +245,7 @@ func (c *Connection) newAPIChannel(reqChanBufSize, replyChanBufSize int) (*Chann return nil, errors.New("nil connection passed in") } - // create new channel - chID := uint16(atomic.AddUint32(&c.maxChannelID, 1) & 0x7fff) - channel := newChannel(chID, c, c.codec, c, reqChanBufSize, replyChanBufSize) - - // store API channel within the client - c.channelsLock.Lock() - c.channels[chID] = channel - c.channelsLock.Unlock() + channel := c.newChannel(reqChanBufSize, replyChanBufSize) // start watching on the request channel go c.watchRequests(channel) -- cgit 1.2.3-korg