From 5367ee76d0390ca7d12c5355cea7a8343385f5df Mon Sep 17 00:00:00 2001 From: Robert Carlsen Date: Tue, 9 Feb 2016 11:09:43 -0600 Subject: [PATCH] fix another panic where CloseNotify was called from wrong goroutine panic: net/http: CloseNotify called after ServeHTTP finished goroutine 180 [running]: net/http.(*response).CloseNotify(0xc8220684e0, 0x0) /home/r/go/src/net/http/server.go:1535 +0x9d github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/prometheus/client_golang/ /home/r/src/github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/prome github.com/ipfs/go-ipfs/core/corehttp.(*gatewayHandler).getOrHeadHandler.func1(0x7 /home/r/src/github.com/ipfs/go-ipfs/core/corehttp/gateway_handler.go:119 + created by github.com/ipfs/go-ipfs/core/corehttp.(*gatewayHandler).getOrHeadHandle /home/r/src/github.com/ipfs/go-ipfs/core/corehttp/gateway_handler.go:123 + License: MIT Signed-off-by: Robert Carlsen --- core/corehttp/gateway_handler.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/corehttp/gateway_handler.go b/core/corehttp/gateway_handler.go index ebf0b3c6e..ca7938346 100644 --- a/core/corehttp/gateway_handler.go +++ b/core/corehttp/gateway_handler.go @@ -114,9 +114,10 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request defer cancel() if cn, ok := w.(http.CloseNotifier); ok { + clientGone := cn.CloseNotify() go func() { select { - case <-cn.CloseNotify(): + case <-clientGone: case <-ctx.Done(): } cancel()