Skip to content

Fix host_socket not set for extra streams on client side#3373

Open
chenBright wants to merge 1 commit into
apache:masterfrom
chenBright:fix_extra_stream
Open

Fix host_socket not set for extra streams on client side#3373
chenBright wants to merge 1 commit into
apache:masterfrom
chenBright:fix_extra_stream

Conversation

@chenBright

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: introduced by PR #2938 .

Problem Summary:

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).

What is changed and the side effects?

Changed:

Set host_socket on the extra stream itself, matching the server-side logic in baidu_rpc_protocol.

Side effects:

  • Performance effects:

  • Breaking backward compatibility:


Check List:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::HandleStreamConnection to set host_socket on 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.

Comment thread test/brpc_streaming_rpc_unittest.cpp Outdated
Comment thread test/brpc_streaming_rpc_unittest.cpp Outdated
Comment thread test/brpc_streaming_rpc_unittest.cpp Outdated
Comment thread test/brpc_streaming_rpc_unittest.cpp
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>
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

Successfully merging this pull request may close these issues.

2 participants