Allow enabled_protocols to name http, h2 and rdma_handshake - #3518
Open
chenBright wants to merge 1 commit into
Open
Allow enabled_protocols to name http, h2 and rdma_handshake#3518chenBright wants to merge 1 commit into
chenBright wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The core logic fix matches the stated problem and is covered by a focused regression test, with only a minor maintainability note remaining.
Pull request overview
This PR fixes ServerOptions.enabled_protocols handling so that specifying always-enabled protocol names (http, h2, rdma_handshake) no longer causes Server::Start() to fail due to leftover “unknown protocol” entries. This aligns enabled_protocols behavior with how the server actually serves builtin HTTP/H2 services and RDMA handshake traffic.
Changes:
- Adjust
Server::BuildAcceptor()to consume whitelisted protocol names even when they’re exempt from filtering (http/h2/rdma_handshake). - Add a unit test covering
enabled_protocolsvalues that include these always-enabled protocol names. - Clarify
ServerOptions::enabled_protocolsdocumentation regarding always-enabled protocols.
File summaries
| File | Description |
|---|---|
src/brpc/server.cpp |
Fixes whitelist consumption logic in BuildAcceptor() so exempt protocols don’t remain as “unknown”. |
src/brpc/server.h |
Documents that http/h2 and rdma_handshake are always served and may be listed in enabled_protocols without effect. |
test/brpc_server_unittest.cpp |
Adds regression coverage to ensure naming always-enabled protocols in enabled_protocols doesn’t break Start(). |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 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:
http,h2andrdma_handshakeare served whateverServerOptions.enabled_protocolssays — the builtin services are only reachable over http/h2, and
rdma_handshakeis atransport level handshake that dispatches no request. But naming any of them in
enabled_protocolsmadeServer::Start()return -1:In
Server::BuildAcceptor()the exemption was tested before the whitelist lookup,inside a single
&&chain:if (has_whitelist && !is_http_protocol(protocols[i].name) && !is_rdma_handshake_protocol(protocols[i].name) && !whitelist.erase(protocols[i].name)) {For an exempted protocol the chain short-circuits at the third condition, so
whitelist.erase()never runs and the name is never consumed. It then survives intothe leftover check at the end of the function and comes back as:
So a user who spelled out every protocol they wanted — including the ones that are
always on anyway — could not start the server at all.
What is changed and the side effects?
Changed:
Side effects:
Performance effects:
Breaking backward compatibility:
Check List: