Skip to content

Commit

Permalink
Close lisener in server.Close
Browse files Browse the repository at this point in the history
  • Loading branch information
july2993 committed Mar 6, 2023
1 parent 49eaee2 commit 1d62710
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,10 @@ var gracefulCloseConnectionsTimeout = 15 * time.Second
// Close closes the server.
func (s *Server) Close() {
s.startShutdown()
s.rwlock.Lock() // // prevent new connections
defer s.rwlock.Unlock()
s.inShutdownMode.Store(true)
s.closeListener()
}

func (s *Server) registerConn(conn *clientConn) bool {
Expand Down Expand Up @@ -874,8 +878,6 @@ func (s *Server) DrainClients(drainWait time.Duration, cancelWait time.Duration)
conns := make(map[uint64]*clientConn)

s.rwlock.Lock()
s.inShutdownMode.Store(true)
s.closeListener()
for k, v := range s.clients {
conns[k] = v
}
Expand Down

0 comments on commit 1d62710

Please sign in to comment.