close the response chan on header stream erros in h2quic client

This commit is contained in:
Marten Seemann
2017-05-06 11:55:56 +08:00
parent b7d7a8447d
commit fb77a79b2b
2 changed files with 6 additions and 10 deletions

View File

@@ -123,7 +123,7 @@ func (c *Client) handleHeaderStream() {
utils.Debugf("Error handling header stream %d: %s", lastStream, c.headerErr.Error())
c.mutex.Lock()
for _, responseChan := range c.responses {
responseChan <- nil
close(responseChan)
}
c.mutex.Unlock()
}
@@ -142,14 +142,14 @@ func (c *Client) Do(req *http.Request) (*http.Response, error) {
hasBody := (req.Body != nil)
<-c.dialChan // wait until the handshake has completed
hdrChan := make(chan *http.Response)
responseChan := make(chan *http.Response)
dataStream, err := c.session.OpenStreamSync()
if err != nil {
c.Close(err)
return nil, err
}
c.mutex.Lock()
c.responses[dataStream.StreamID()] = hdrChan
c.responses[dataStream.StreamID()] = responseChan
c.mutex.Unlock()
var requestedGzip bool
@@ -182,7 +182,7 @@ func (c *Client) Do(req *http.Request) (*http.Response, error) {
for !(bodySent && receivedResponse) {
select {
case res = <-hdrChan:
case res = <-responseChan:
receivedResponse = true
c.mutex.Lock()
delete(c.responses, dataStream.StreamID())