lizining1231 commented on code in PR #3645:
URL: https://github.com/apache/dubbo-go/pull/3645#discussion_r3788810425
##########
protocol/triple/triple_protocol/server.go:
##########
@@ -264,6 +270,28 @@ func (s *Server) startHttp2AndHttp3(tlsConf *tls.Config)
error {
return err
}
+ if len(tlsConf.Certificates) == 0 &&
+ tlsConf.GetCertificate == nil &&
+ tlsConf.GetConfigForClient == nil {
+ return fmt.Errorf("TRIPLE HTTP/2 and HTTP/3 Server must have a
TLS certificate configured, but none of
Certificates/GetCertificate/GetConfigForClient is set")
+ }
+
+ // Pre-bind the TCP (HTTP/2) listener before serving any request:
+ // fail fast with the bind error when the port is occupied.
+ tcpLn, err := netListen("tcp", s.addr)
+ if err != nil {
+ return fmt.Errorf("HTTP/2 server bind error: %w", err)
+ }
+ defer tcpLn.Close()
+
Review Comment:
好的,感谢 review!针对两个单协议路径的启动窗口竞态,我已做出改动,具体如下:
1. 代码改动
- `Run` 的 switch 分支将启动 `epoch` 传给单协议启动函数 `startHttp2` / `startHttp3`
- 两个函数在 `Store` 发布 server 指针之后、开始监听之前,新增第二次 `epoch` 检查:若 `stopCount` 与登记
epoch 不一致(说明有 Stop 落地),则直接 `return nil` 放弃启动,不进入监听
- 该检查点与双协议路径 `startHttp2AndHttp3` 中已有的检查点保持同构,覆盖入口检查通过后、server 发布前/刚发布的竞态窗口
2. 测试改动
- 新增 `TestServer_HTTP2_StopBetweenCheckpointAndServeAbortsStartup` 与
`TestServer_HTTP3_StopBetweenCheckpointAndServeAbortsStartup`
- 与双协议路径测试逻辑不同,先调用 `BeginStart()` 登记 epoch,再调用 `Stop()` 递增停止计数,然后以过期的
`epoch` 直接调用 `startHttp2` / `startHttp3`——这样确定性命中 Store 后的检查点 abort 分支,不依赖并发时序
- `server` 指针已发布,且 TCP/UDP 端口可重新绑定(无监听残留)
--
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]