|
|
@@ -753,9 +753,13 @@ func (sc *serverConn) serve() {
|
|
|
sc.idleTimerCh = sc.idleTimer.C
|
|
|
}
|
|
|
|
|
|
- var gracefulShutdownCh <-chan struct{}
|
|
|
+ var gracefulShutdownCh chan struct{}
|
|
|
if sc.hs != nil {
|
|
|
- gracefulShutdownCh = h1ServerShutdownChan(sc.hs)
|
|
|
+ ch := h1ServerShutdownChan(sc.hs)
|
|
|
+ if ch != nil {
|
|
|
+ gracefulShutdownCh = make(chan struct{})
|
|
|
+ go sc.awaitGracefulShutdown(ch, gracefulShutdownCh)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
go sc.readFrames() // closed by defer sc.conn.Close above
|
|
|
@@ -808,6 +812,14 @@ func (sc *serverConn) serve() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func (sc *serverConn) awaitGracefulShutdown(sharedCh <-chan struct{}, privateCh chan struct{}) {
|
|
|
+ select {
|
|
|
+ case <-sc.doneServing:
|
|
|
+ case <-sharedCh:
|
|
|
+ close(privateCh)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// readPreface reads the ClientPreface greeting from the peer
|
|
|
// or returns an error on timeout or an invalid greeting.
|
|
|
func (sc *serverConn) readPreface() error {
|