server: use Atomic.Pointer in the Server.statusServer (#62903)

close pingcap/tidb#62902
This commit is contained in:
Weizhen Wang
2025-08-08 19:05:00 +08:00
committed by GitHub
parent 857a162ea4
commit 5c7794c2e2
2 changed files with 5 additions and 5 deletions

View File

@ -586,7 +586,7 @@ func (s *Server) startStatusServerAndRPCServer(serverMux *http.ServeMux) {
}
}
s.statusServer = statusServer
s.statusServer.Store(statusServer)
s.grpcServer = grpcServer
go util.WithRecovery(func() {

View File

@ -142,7 +142,7 @@ type Server struct {
statusAddr string
statusListener net.Listener
statusServer *http.Server
statusServer atomic.Pointer[http.Server]
grpcServer *grpc.Server
inShutdownMode *uatomic.Bool
health *uatomic.Bool
@ -643,10 +643,10 @@ func (s *Server) closeListener() {
terror.Log(errors.Trace(err))
s.socket = nil
}
if s.statusServer != nil {
err := s.statusServer.Close()
if statusServer := s.statusServer.Load(); statusServer != nil {
err := statusServer.Close()
terror.Log(errors.Trace(err))
s.statusServer = nil
s.statusServer.Store(nil)
}
if s.grpcServer != nil {
s.grpcServer.Stop()