connection: prevent channel ID overlap 50/35150/2
authorLukas Vogel <vogel@anapaya.net>
Mon, 31 Jan 2022 10:33:37 +0000 (11:33 +0100)
committerLukas Vogel <vogel@anapaya.net>
Mon, 31 Jan 2022 10:53:39 +0000 (11:53 +0100)
commitb9aa34d5f77ac5969ad273bfd187ce5f9594b25e
treefd87cf2331ce8008128e1f29c565e9381f2fb440
parent000215c229d6df2c1a68b50847d8c7abf3842ce5
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>
core/channel.go
core/connection.go
core/stream.go