Fix host_socket not set for extra streams on client side#3373
Open
chenBright wants to merge 1 commit into
Open
Fix host_socket not set for extra streams on client side#3373chenBright wants to merge 1 commit into
chenBright wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a client-side streaming bug where extra streams created in a batch could reach Stream::SetConnected() without having host_socket set (especially when no downstream data is received), aligning the client behavior with the server-side baidu_rpc_protocol logic. It also adds regression tests to cover extra-stream connectivity in both downstream and upstream-only scenarios.
Changes:
- Fix
Controller::HandleStreamConnectionto sethost_socketon each extra stream (not the first stream repeatedly). - Add new unit tests validating that batch-created extra streams become connected and function correctly even with no downstream traffic.
- Minor formatting/.gitignore updates.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/brpc/controller.cpp |
Correctly sets host_socket on each extra stream during client-side stream connection handling. |
test/brpc_streaming_rpc_unittest.cpp |
Adds regression coverage for batch-created extra streams, including an upstream-only case. |
src/brpc/socket.cpp |
Minor formatting change for duetime initialization. |
.gitignore |
Ignores MODULE.bazel.lock. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Controller::HandleStreamConnection called s->SetHostSocket() on the first stream inside the extra-stream loop. When an extra stream carried no downstream data (nothing triggered Stream::OnReceived to set host_socket for it), Stream::SetConnected() hit CHECK(_host_socket != NULL). Set host_socket on the extra stream itself, matching the server-side logic in baidu_rpc_protocol. Co-authored-by: jiangyt-git <64257436+jiangyt-git@users.noreply.github.com> Co-authored-by: jiangyuting <jiangyutingwangyi@163.com>
c4af58c to
5c97643
Compare
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: introduced by PR #2938 .
Problem Summary:
Controller::HandleStreamConnectioncalleds->SetHostSocket()on the first stream inside the extra-stream loop. When an extra stream carried no downstream data (nothing triggeredStream::OnReceived()to sethost_socketfor it),Stream::SetConnected()hitCHECK(_host_socket != NULL).What is changed and the side effects?
Changed:
Set
host_socketon the extra stream itself, matching the server-side logic in baidu_rpc_protocol.Side effects:
Performance effects:
Breaking backward compatibility:
Check List: