mirror of https://github.com/grpc/grpc-go.git
refactor GracefulStop a bit
This commit is contained in:
parent
5a547ed72c
commit
0f3fc4355d
|
@ -797,8 +797,8 @@ func (s *Server) Stop() {
|
||||||
// connections and RPCs and blocks until all the pending RPCs are finished.
|
// connections and RPCs and blocks until all the pending RPCs are finished.
|
||||||
func (s *Server) GracefulStop() {
|
func (s *Server) GracefulStop() {
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
|
defer s.mu.Unlock()
|
||||||
if s.drain == true || s.conns == nil {
|
if s.drain == true || s.conns == nil {
|
||||||
s.mu.Unlock()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.drain = true
|
s.drain = true
|
||||||
|
@ -817,7 +817,6 @@ func (s *Server) GracefulStop() {
|
||||||
s.events.Finish()
|
s.events.Finish()
|
||||||
s.events = nil
|
s.events = nil
|
||||||
}
|
}
|
||||||
s.mu.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
Loading…
Reference in New Issue