diff --git a/bfe_http/transport.go b/bfe_http/transport.go index a322338a..90bd9b19 100644 --- a/bfe_http/transport.go +++ b/bfe_http/transport.go @@ -885,6 +885,10 @@ func (pc *persistConn) readLoop() { err = ReadRespHeaderError{Err: err} } + pc.lk.Lock() + pc.numExpectedResponses-- + pc.lk.Unlock() + rc.ch <- responseAndError{resp, err} // Wait for the just-returned response body to be fully consumed @@ -1051,10 +1055,6 @@ WaitResponse: } } - pc.lk.Lock() - pc.numExpectedResponses-- - pc.lk.Unlock() - if re.err != nil { pc.t.setReqConn(req.Request, nil) }