chenBright opened a new pull request, #3518:
URL: https://github.com/apache/brpc/pull/3518
### What problem does this PR solve?
Issue Number: resolve
Problem Summary:
`http`, `h2` and `rdma_handshake` are served whatever
`ServerOptions.enabled_protocols`
says — the builtin services are only reachable over http/h2, and
`rdma_handshake` is a
transport level handshake that dispatches no request. But naming any of
them in
`enabled_protocols` made `Server::Start()` return -1:
```cpp
enabled_protocols = "baidu_std http" -> Server::Start() returns
-1
enabled_protocols = "baidu_std h2" -> Server::Start() returns
-1
enabled_protocols = "baidu_std rdma_handshake" -> Server::Start() returns
-1
```
In `Server::BuildAcceptor()` the exemption was tested *before* the whitelist
lookup,
inside a single `&&` chain:
```cpp
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 into
the leftover check at the end of the function and comes back as:
```
ServerOptions.enabled_protocols has unknown protocols=`http '
```
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:
- 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]