From 0f3fc4355d23980249b40b456977aa9a3a3b7296 Mon Sep 17 00:00:00 2001 From: iamqizhao Date: Fri, 29 Jul 2016 10:59:24 -0700 Subject: [PATCH] refactor GracefulStop a bit --- server.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server.go b/server.go index 23c4629e..9e239a46 100644 --- a/server.go +++ b/server.go @@ -797,8 +797,8 @@ func (s *Server) Stop() { // connections and RPCs and blocks until all the pending RPCs are finished. func (s *Server) GracefulStop() { s.mu.Lock() + defer s.mu.Unlock() if s.drain == true || s.conns == nil { - s.mu.Unlock() return } s.drain = true @@ -817,7 +817,6 @@ func (s *Server) GracefulStop() { s.events.Finish() s.events = nil } - s.mu.Unlock() } func init() {