Validate returned stream identifiers - #3485
Open
wasphin wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR hardens multi-stream RPC handling by validating that the server returns exactly one extra_stream_id per additional client stream, and adds regression coverage for both missing and surplus returned identifiers.
Changes:
- Add a client-side validation that
extra_stream_ids_size == stream_num - 1and fail withERESPONSEon mismatch. - Introduce a test service that intentionally returns mismatched
extra_stream_ids. - Add a unit test asserting the mismatch is rejected and that streams are cleaned up.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/brpc_streaming_rpc_unittest.cpp | Adds regression tests for missing/surplus extra_stream_ids using a custom test service. |
| src/brpc/controller.cpp | Adds validation of returned extra_stream_ids count and fails the RPC on mismatch. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: resolve
Problem Summary:
When a client creates multiple streams in one RPC, it expects the server response to return exactly one
extra_stream_idfor every stream after the first. The response path indexed this list using the number of locally created streams without first validating its size. A malformed response could therefore read past the returned identifiers, while surplus identifiers had no valid client-stream mapping.What is changed and the side effects?
Changed:
extra_stream_idsto exactly match the number of additional client streams.ERESPONSEand use the existing stream cleanup path when the counts differ.Side effects:
Performance effects: One integer comparison is added when completing a multi-stream RPC.
Breaking backward compatibility: Malformed responses with missing or surplus stream identifiers are now rejected instead of being partially processed.
Check List: