rafthttp: always cancel in-flight request when pipeline.send
This fits the way for go1.5 to cancel request.
This commit is contained in:
@ -223,18 +223,6 @@ func newRoundTripperBlocker() *roundTripperBlocker {
|
||||
cancel: make(map[*http.Request]chan struct{}),
|
||||
}
|
||||
}
|
||||
func (t *roundTripperBlocker) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
c := make(chan struct{}, 1)
|
||||
t.mu.Lock()
|
||||
t.cancel[req] = c
|
||||
t.mu.Unlock()
|
||||
select {
|
||||
case <-t.unblockc:
|
||||
return &http.Response{StatusCode: http.StatusNoContent, Body: &nopReadCloser{}}, nil
|
||||
case <-c:
|
||||
return nil, errors.New("request canceled")
|
||||
}
|
||||
}
|
||||
func (t *roundTripperBlocker) unblock() {
|
||||
close(t.unblockc)
|
||||
}
|
||||
|
Reference in New Issue
Block a user