Skip to content

Commit

Permalink
http3: fix graceful server shutdown (quic-go#4707)
Browse files Browse the repository at this point in the history
* close connHandlingDone once only when the server is shutting down

* close underlying listeners during graceful  shutdown when there is no connection

* remove connDoneOnce
  • Loading branch information
WeidiDeng authored Oct 22, 2024
1 parent 6af2b1a commit 98de6ae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions http3/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func (s *Server) init() {
}

func (s *Server) decreaseConnCount() {
if s.connCount.Add(-1) == 0 {
if s.connCount.Add(-1) == 0 && s.graceCtx.Err() != nil {
close(s.connHandlingDone)
}
}
Expand Down Expand Up @@ -762,7 +762,7 @@ func (s *Server) Shutdown(ctx context.Context) error {
s.mutex.Unlock()

if s.connCount.Load() == 0 {
return nil
return s.Close()
}
select {
case <-s.connHandlingDone: // all connections were closed
Expand Down

0 comments on commit 98de6ae

Please sign in to comment.