| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
This PR prevents the server process from aborting when binding response streams to a host socket that has already failed (e.g., peer disconnects between StreamAccept() and response send), turning it into a normal RPC/stream failure path.
Changes:
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/brpc/stream.cpp | Converts host-socket bind from fatal abort to error return. |
| src/brpc/policy/baidu_rpc_protocol.cpp | Handles stream bind failures in SendRpcResponse() and ensures response-write completion is joined on early returns. |
| test/brpc_streaming_rpc_unittest.cpp | Adds regression tests for failed-socket bind and server-side early disconnect. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
|
Thanks for the review. Addressed all Copilot comments:
|
Sorry, something went wrong.
|
@chenBright could you please review this pr again |
Sorry, something went wrong.
| Stream::SetFailed(response_stream_ids, errcode, | ||
| "Fail to bind response stream to %s", | ||
| sock->description().c_str()); | ||
| return; |
There was a problem hiding this comment.
I think that if binding the response stream fails, we shouldn't just return directly; we should still try writing a response.
Sorry, something went wrong.
| cntl->SetFailed(errcode, "Fail to bind response stream to %s", | ||
| sock->description().c_str()); |
There was a problem hiding this comment.
Just call cntl->SetFailed once.
Sorry, something went wrong.
| s->FillSettings(stream_settings); | ||
| s->SetHostSocket(sock); | ||
| if (s->SetHostSocket(sock) != 0) { | ||
| const int errcode = errno; |
There was a problem hiding this comment.
Why use errno as the reason for SetHostSocket failure? SetHostSocket failure does not set errno.
Sorry, something went wrong.
@amoxic Sorry, I missed the message. I've already reviewed the PR. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
What problem does this PR solve?
Issue Number: resolves #3245
Problem Summary:
When a peer disconnects after StreamAccept() succeeds but before the RPC response binds the response stream to the host socket, Socket::AddStream() can fail inside Stream::SetHostSocket(). The previous code treated this as an impossible state and aborted the server with CHECK(false).
This PR turns that path into a normal runtime failure so the current RPC/stream is failed and the server process stays alive.
What is changed and the side effects?
Changed:
Side effects:
Performance effects:
No expected steady-state performance impact. Extra work is only added on the error path.
Breaking backward compatibility:
No API change. The behavior changes from process abort to RPC/stream failure when the host socket is already failed.
Check List: