mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver/etcdhttp: cancel wait on conn close
This commit is contained in:
parent
665af71888
commit
8c3450e200
@ -58,8 +58,15 @@ func encodeResponse(ctx context.Context, w http.ResponseWriter, resp etcdserver.
|
|||||||
case resp.Watcher != nil:
|
case resp.Watcher != nil:
|
||||||
// TODO(bmizerany): support streaming?
|
// TODO(bmizerany): support streaming?
|
||||||
defer resp.Watcher.Remove()
|
defer resp.Watcher.Remove()
|
||||||
|
var nch <-chan bool
|
||||||
|
if x, ok := w.(http.CloseNotifier); ok {
|
||||||
|
nch = x.CloseNotify()
|
||||||
|
}
|
||||||
select {
|
select {
|
||||||
case ev = <-resp.Watcher.EventChan:
|
case ev = <-resp.Watcher.EventChan:
|
||||||
|
case <-nch:
|
||||||
|
// TODO: log something?
|
||||||
|
return nil
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user