In gracefull stop close server transport only after flushing status of the last stream. (#1734)

This commit is contained in:
mmukhi
2017-12-13 16:09:49 -08:00
committed by GitHub
parent d1fc8fa770
commit 8fba5fc8fd
2 changed files with 9 additions and 2 deletions

View File

@ -116,6 +116,7 @@ type goAway struct {
func (*goAway) item() {}
type flushIO struct {
closeTr bool
}
func (*flushIO) item() {}

View File

@ -1107,7 +1107,13 @@ func (t *http2Server) itemHandler(i item) error {
}()
return nil
case *flushIO:
return t.framer.writer.Flush()
if err := t.framer.writer.Flush(); err != nil {
return err
}
if i.closeTr {
t.Close()
}
return nil
case *ping:
if !i.ack {
t.bdpEst.timesnap(i.data)
@ -1155,7 +1161,7 @@ func (t *http2Server) closeStream(s *Stream) {
t.idle = time.Now()
}
if t.state == draining && len(t.activeStreams) == 0 {
defer t.Close()
defer t.controlBuf.put(&flushIO{closeTr: true})
}
t.mu.Unlock()
// In case stream sending and receiving are invoked in separate