fix cli shutdown panic

This commit is contained in:
fancl 2024-06-14 11:32:20 +08:00
parent 7fff2f8a1c
commit b28dbdb8c1
1 changed files with 3 additions and 1 deletions
entry/cli

View File

@ -210,7 +210,9 @@ func (svr *Server) Shutdown() (err error) {
if !atomic.CompareAndSwapInt32(&svr.exitFlag, 0, 1) { if !atomic.CompareAndSwapInt32(&svr.exitFlag, 0, 1) {
return return
} }
err = svr.l.Close() if svr.l != nil {
err = svr.l.Close()
}
svr.ctxMap.Range(func(key, value any) bool { svr.ctxMap.Range(func(key, value any) bool {
if ctx, ok := value.(*Context); ok { if ctx, ok := value.(*Context); ok {
err = ctx.Close() err = ctx.Close()