Skip to content

Commit

Permalink
Wait until reader go exits in Close()
Browse files Browse the repository at this point in the history
It was not guaranteed that when `transport.Close()` returned, the
reader go-routines terminated. All the other channels like,  `ctxDone`, `writerDone`, `goAway` are being waited upon for a signal

To ensure that `transport.Close()` only return after the reader go-routine terminates:

- Wait for the `readerDone` channel to signal the completion 

This fixes: grpc#2869

RELEASE NOTES:

grpc: Wait until reader go routine exits in transport.Close()
  • Loading branch information
eshitachandwani authored Aug 23, 2024
1 parent e4b09f1 commit 03467ac
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions internal/transport/http2_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,7 @@ func (t *http2Client) Close(err error) {
case <-timer.C:
t.logger.Infof("Failed to write a GOAWAY frame as part of connection close after %s. Giving up and closing the transport.", goAwayLoopyWriterTimeout)
}
<-t.readerDone
t.cancel()
t.conn.Close()
channelz.RemoveEntry(t.channelz.ID)
Expand Down

0 comments on commit 03467ac

Please sign in to comment.