Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StreamId overflow and reuse #892

Open
linux-china opened this issue Jul 26, 2019 · 0 comments
Open

StreamId overflow and reuse #892

linux-china opened this issue Jul 26, 2019 · 0 comments

Comments

@linux-china
Copy link

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant