lizining1231 commented on code in PR #3645:
URL: https://github.com/apache/dubbo-go/pull/3645#discussion_r3785920606
##########
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!针对 Stop 在 goroutine 读取 stopCount 前完成会无效 的窗口问题,我已做出以下改动:
1. 代码改动
- 新增 `BeginStart()` 在 `startTransport` 的同步路径上登记启动 `epoch`,调用时机在传输 `goroutine
启动` 之前 ,防止 goroutine 调度延迟导致对比失效从而导致`stop`失效
- `Run` 增加 `epoch` 参数,入口新增检查点:比对登记值与当前 `stopCount` ,若 `Stop` 在登记后、`Run`
执行前落地,则在 `bind` 任何 `socket` 之前 中止启动
- 入口检查点覆盖所有协议路径(`HTTP/2 / HTTP/3 / 双协议`), `startHttp2AndHttp3` 内部的 bind
期间检查点保留
2. 测试改动
- 新增 `TestServer_HTTP2AndHTTP3_StopBeforeRunAbortsStartup`测试 :同步登记 `epoch →
Stop → Run` ,断言 `Run` 在 3s 内返回、TCP 端口可重新绑定(无 `listener` 泄漏),覆盖双协议路径
- 新增 `TestServer_HTTP2_StopBeforeRunAbortsStartup`测试 :同一时序,覆盖单协议(HTTP/2)路径
--
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]