StreamId overflow and reuse
linux-china opened this issue · 0 comments
linux-china commented
Please consider to adopt Java solution: https://github.com/rsocket/rsocket-java/blob/develop/rsocket-core/src/main/java/io/rsocket/StreamIdSupplier.java
getNextStreamId() in rsocket-cpp SDK.
StreamId RSocketStateMachine::getNextStreamId() {
constexpr auto limit =
static_cast<uint32_t>(std::numeric_limits<int32_t>::max() - 2);
auto const streamId = nextStreamId_;
if (streamId >= limit) {
throw std::runtime_error{"Ran out of stream IDs"};
}
CHECK_EQ(0, streams_.count(streamId))
<< "Next stream ID already exists in the streams map";
nextStreamId_ += 2;
return streamId;
}