From 35ca3304ff4b325299e68f59b325bd208425fca2 Mon Sep 17 00:00:00 2001 From: Christy Perez Date: Mon, 18 Jan 2016 14:19:41 -0600 Subject: [PATCH] Move closeNotify to fix panic with newer golang This is happening now due to improvements in net/http: https://github.com/golang/go/commit/99fb19194c03c618c0d8faa87b91ba419ae28ee3 To test, change the go version in the Dockerfile: -ENV GO_VERSION 1.5.3 +ENV GO_VERSION 1.6beta2 More info here: https://github.com/golang/go/issues/14001 Signed-off-by: Christy Perez --- api/server/router/build/build_routes.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/server/router/build/build_routes.go b/api/server/router/build/build_routes.go index 2962d87f35..25e8fbcfff 100644 --- a/api/server/router/build/build_routes.go +++ b/api/server/router/build/build_routes.go @@ -241,10 +241,11 @@ func (br *buildRouter) postBuild(ctx context.Context, w http.ResponseWriter, r * if closeNotifier, ok := w.(http.CloseNotifier); ok { finished := make(chan struct{}) defer close(finished) + clientGone := closeNotifier.CloseNotify() go func() { select { case <-finished: - case <-closeNotifier.CloseNotify(): + case <-clientGone: logrus.Infof("Client disconnected, cancelling job: build") b.Cancel() }