Skip to content

Commit

Permalink
Move locking to include checking for server and calling server.Close()
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
  • Loading branch information
kozlovic authored and wallyqs committed May 8, 2024
1 parent cc544f2 commit ec58b06
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2478,14 +2478,14 @@ func (s *Server) Shutdown() {
}

// Kick websocket server
s.websocket.mu.Lock()
if s.websocket.server != nil {
doneExpected++
s.websocket.server.Close()
s.websocket.mu.Lock()
s.websocket.server = nil
s.websocket.listener = nil
s.websocket.mu.Unlock()
}
s.websocket.mu.Unlock()

// Kick MQTT accept loop
if s.mqtt.listener != nil {
Expand Down Expand Up @@ -4092,14 +4092,14 @@ func (s *Server) lameDuckMode() {
expected := 1
s.listener.Close()
s.listener = nil
s.websocket.mu.Lock()
if s.websocket.server != nil {
expected++
s.websocket.server.Close()
s.websocket.mu.Lock()
s.websocket.server = nil
s.websocket.listener = nil
s.websocket.mu.Unlock()
}
s.websocket.mu.Unlock()
s.ldmCh = make(chan bool, expected)
opts := s.getOpts()
gp := opts.LameDuckGracePeriod
Expand Down

0 comments on commit ec58b06

Please sign in to comment.