Skip to content

Commit

Permalink
fix: close connection on shutdown in single port mode
Browse files Browse the repository at this point in the history
Shutdown was not working in single port mode. Close the connection unconditionally when Shutdown is called.
  • Loading branch information
utkuozdemir committed Oct 21, 2024
1 parent e69c06d commit 0dd7dba
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,13 @@ func (s *Server) processRequest() error {
// Shutdown blocks until all outstanding requests are processed or timed out.
// Calling Shutdown from the handler or hook might cause deadlock.
func (s *Server) Shutdown() {
if !s.singlePort {
s.Lock()
// Connection could not exist if Serve or
// ListenAndServe was never called.
if s.conn != nil {
s.conn.Close()
}
s.Unlock()
s.Lock()
// Connection could not exist if Serve or
// ListenAndServe was never called.
if s.conn != nil {
s.conn.Close()
}
s.Unlock()
s.cancelFn()
if !s.singlePort {
s.wg.Wait()
Expand Down

0 comments on commit 0dd7dba

Please sign in to comment.