AlexStocks commented on code in PR #3645:
URL: https://github.com/apache/dubbo-go/pull/3645#discussion_r3780863830


##########
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:
   [P1] 当前修复仍遗漏了更早的启动窗口:`startTransport` 通过 goroutine 异步调用 `Run`,但 generation 
直到这里真正执行时才读取。如果 `Stop` 在该 goroutine 读取 `stopCount` 前已经完成,`Run` 
会把递增后的值当作新基线并继续监听。固定当前 Head 的确定性探针先让 `Stop` 完成、再释放 `Run`,第一次 `Stop` 
返回后服务仍未退出,必须再次 `Stop` 才能回收。建议在异步启动请求入队前同步登记 generation/state,或让启动入口等待 lifecycle 
注册完成,并补充“Stop 完成于 epoch 读取之前”的回归测试。



##########
protocol/triple/triple_protocol/server.go:
##########
@@ -46,12 +47,18 @@ import (
        "dubbo.apache.org/dubbo-go/v3/protocol/triple/openapi"
 )
 
+// netListen and netListenPacket create the pre-bound sockets in
+// startHttp2AndHttp3. Tests override them to simulate Serve failures.
+var netListen = net.Listen

Review Comment:
   so ugly codes.
   ```go
   var (
   netListen net.Listen
   netListenPacket net.ListenPacket
   )



-- 
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]

Reply via email to