forked from quic-go/quic-go
http3: fix graceful server shutdown (#4707)
* close connHandlingDone once only when the server is shutting down * close underlying listeners during graceful shutdown when there is no connection * remove connDoneOnce
This commit is contained in:
@@ -285,7 +285,7 @@ func (s *Server) init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) decreaseConnCount() {
|
func (s *Server) decreaseConnCount() {
|
||||||
if s.connCount.Add(-1) == 0 {
|
if s.connCount.Add(-1) == 0 && s.graceCtx.Err() != nil {
|
||||||
close(s.connHandlingDone)
|
close(s.connHandlingDone)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -762,7 +762,7 @@ func (s *Server) Shutdown(ctx context.Context) error {
|
|||||||
s.mutex.Unlock()
|
s.mutex.Unlock()
|
||||||
|
|
||||||
if s.connCount.Load() == 0 {
|
if s.connCount.Load() == 0 {
|
||||||
return nil
|
return s.Close()
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case <-s.connHandlingDone: // all connections were closed
|
case <-s.connHandlingDone: // all connections were closed
|
||||||
|
|||||||
Reference in New Issue
Block a user