chenBright opened a new pull request, #3505: URL: https://github.com/apache/brpc/pull/3505
### What problem does this PR solve? Issue Number: resolve #3479 Problem Summary: ### What is changed and the side effects? Changed: 1. One input stream, one buffer. New `InputMessengerProcessor` holds the state of a single input stream: its `butil::IOPortal` and the message-size statistics that size the next read. `Socket::_read_buf`, `_last_msg_size` and `_avg_msg_size` move into it, and `InputMessenger::CutInputMessage()` / `ProcessNewMessage()` become its methods. A `Socket` owns one for its fd, a `RdmaEndpoint` owns one for its QP. `Socket::DoRead()` now takes the destination `IOPortal*` instead of always filling `_read_buf`. 2. The server stops parsing the TCP fd once RDMA is on (scenario 1). `RdmaTransport::Init()` installs `RdmaEndpoint::OnNewDataFromTcp` for both sides rather than only for the client; it dispatches on `Socket::CreatedByConnect()`. In `ESTABLISHED` the fd is only probed for EOF, never parsed. This is needed on top of the buffer split because `preferred_index` and `parsing_context` are still per-Socket, so two streams must not parse at once. 3. CQ events start after the handshake, not during it (scenarios 2). `RdmaEndpoint::StartCqEvents()` is split out of `DoAllocateResources()`. The server calls it from `OnNewDataFromTcpAtServer()` once `OnNewMessages()` has returned, the client from `ProcessHandshakeAtClient()`. No CQE is lost by deferring: `BringUpQp()` fills the RQ and `DoAllocateResources()` arms both CQs before the QP reaches RTS, and adding an already readable fd to an edge-triggered epoll reports it immediately. 4. The handshake ACK no longer swallows what follows it (scenario 3). Phase 2 consumes exactly `HELLO_ACK_LEN` bytes and leaves the rest to the real protocol when the connection falls back to TCP. When RDMA is on the fd is not an RPC channel any more, so bytes on it stay a protocol error, and a guard at the top of `ExecuteServerHandshake()` turns them away once the endpoint has left the handshake. Side effects: - Performance effects: - Breaking backward compatibility: --- ### Check List: - Please make sure your changes are compilable. - When providing us with a new feature, it is best to add related tests. - Please follow [Contributor Covenant Code of Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
