Merge pull request #6413 from aaronknister/http_goroutine_leak

Prevent goroutine leak from persistent http connections
pull/6414/head
Jonathan A. Sternberg 2016-04-18 15:19:24 -04:00
commit 5a53fc5d0d
2 changed files with 10 additions and 2 deletions

View File

@ -27,6 +27,7 @@
- [#6383](https://github.com/influxdata/influxdb/pull/6383): Recover from a panic during query execution.
- [#3369](https://github.com/influxdata/influxdb/issues/3369): Detect when a timer literal will overflow or underflow the query engine.
- [#6398](https://github.com/influxdata/influxdb/issues/6398): Fix CREATE RETENTION POLICY parsing so it doesn't consume tokens it shouldn't.
- [#6413](https://github.com/influxdata/influxdb/pull/6413): Prevent goroutine leak from persistent http connections. Thanks @aaronknister.
## v0.12.1 [2016-04-08]

View File

@ -294,9 +294,16 @@ func (h *Handler) serveQuery(w http.ResponseWriter, r *http.Request, user *meta.
closing := make(chan struct{})
if notifier, ok := w.(http.CloseNotifier); ok {
notify := notifier.CloseNotify()
done := make(chan struct{})
defer close(done)
go func() {
<-notify
close(closing)
// Wait for either the request to finish
// or for the client to disconnect
select {
case <-done:
case <-notify:
close(closing)
}
}()
} else {
defer close(closing)