fix(server): 添加 shutdownServers nil ctx 防御性检查
防止 ctx 参数为 nil 时导致 panic: - nil ctx 时使用 context.Background() 作为默认值 - 防御性检查确保函数健壮性 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
d856e3c570
commit
28be9e7e66
@ -1138,6 +1138,10 @@ func (s *Server) registerProxyRoutes(router *handler.Router, serverCfg *config.S
|
|||||||
// 返回值:
|
// 返回值:
|
||||||
// - error: 聚合错误,无错误或全部成功时返回 nil
|
// - error: 聚合错误,无错误或全部成功时返回 nil
|
||||||
func shutdownServers(ctx context.Context, servers []*fasthttp.Server) error {
|
func shutdownServers(ctx context.Context, servers []*fasthttp.Server) error {
|
||||||
|
// 防御性检查:nil ctx 使用默认背景
|
||||||
|
if ctx == nil {
|
||||||
|
ctx = context.Background()
|
||||||
|
}
|
||||||
if len(servers) == 0 {
|
if len(servers) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user