Prioritize ctx.Done() in wait()

This commit is contained in:
Menghan Li
2016-07-22 11:58:19 -07:00
parent 9e57a405e3
commit 5bf353f41b

View File

@ -559,6 +559,12 @@ func wait(ctx context.Context, done, goAway, closing <-chan struct{}, proceed <-
case <-closing: case <-closing:
return 0, ErrConnClosing return 0, ErrConnClosing
case i := <-proceed: case i := <-proceed:
// User cancellation has precedence.
select {
case <-ctx.Done():
return 0, ContextErr(ctx.Err())
default:
}
return i, nil return i, nil
} }
} }