aboutsummaryrefslogtreecommitdiffstats
path: root/core/stream.go
diff options
context:
space:
mode:
authorLukas Vogel <vogel@anapaya.net>2022-01-31 11:33:37 +0100
committerLukas Vogel <vogel@anapaya.net>2022-01-31 11:53:39 +0100
commitb9aa34d5f77ac5969ad273bfd187ce5f9594b25e (patch)
treefd87cf2331ce8008128e1f29c565e9381f2fb440 /core/stream.go
parent000215c229d6df2c1a68b50847d8c7abf3842ce5 (diff)
connection: prevent channel ID overlap
When creating a new channel and the channel ID wraps around, make sure to not re-use a channel ID that is still in use. Re-using the channel ID usually means that the connection health check will stop working and other things might break as well. Also rename maxChannelID to nextChannelID and use a lock to guard access instead of using an atomic. The lock does anyway need to be acquired because to put the entry in the map. This commit was inspired by the following PR on Github: https://github.com/FDio/govpp/pull/14. Change-Id: I8c1a4ca63a53d07a6482b6047a3005065168c0b4 Signed-off-by: Lukas Vogel <vogel@anapaya.net>
Diffstat (limited to 'core/stream.go')
-rw-r--r--core/stream.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/core/stream.go b/core/stream.go
index 2f639b0..67236f1 100644
--- a/core/stream.go
+++ b/core/stream.go
@@ -56,7 +56,11 @@ func (c *Connection) NewStream(ctx context.Context, options ...api.StreamOption)
option(s)
}
- s.channel = c.newChannel(s.requestSize, s.replySize)
+ ch, err := c.newChannel(s.requestSize, s.replySize)
+ if err != nil {
+ return nil, err
+ }
+ s.channel = ch
s.channel.SetReplyTimeout(s.replyTimeout)
// Channel.watchRequests are not started here intentionally, because