mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
rafthttp: wait 1ms before enabling cancel
CancelRequest only effects on in-flight request, so we need to wait for Do(request) called before enabling cancel.
This commit is contained in:
parent
cd629c9b44
commit
29dca49cb5
@ -153,6 +153,7 @@ func (p *pipeline) post(data []byte) (err error) {
|
||||
select {
|
||||
case <-done:
|
||||
case <-p.stopc:
|
||||
waitSchedule()
|
||||
stopped = true
|
||||
if cancel, ok := p.tr.(canceler); ok {
|
||||
cancel.CancelRequest(req)
|
||||
@ -199,3 +200,6 @@ func (p *pipeline) post(data []byte) (err error) {
|
||||
return fmt.Errorf("unexpected http status %s while posting to %q", http.StatusText(resp.StatusCode), req.URL.String())
|
||||
}
|
||||
}
|
||||
|
||||
// waitSchedule waits other goroutines to be scheduled for a while
|
||||
func waitSchedule() { time.Sleep(time.Millisecond) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user