transport: fix race between operateHeaders and closeStream and reading headers (#3062)
headerChan isn't necessarily closed when closeStream returns; block on it in waitOnHeader.
This commit is contained in:
@ -320,6 +320,9 @@ func (s *Stream) waitOnHeader() {
|
||||
// this function returns.
|
||||
err := ContextErr(s.ctx.Err())
|
||||
s.ct.closeStream(s, err, false, 0, status.Convert(err), nil, false)
|
||||
// headerChan could possibly not be closed yet if closeStream raced
|
||||
// with operateHeaders; wait until it is closed explicitly here.
|
||||
<-s.headerChan
|
||||
case <-s.headerChan:
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user