Move closeNotify to fix panic with newer golang

This is happening now due to improvements in net/http:
99fb19194c

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 <christy@linux.vnet.ibm.com>
This commit is contained in:
Christy Perez 2016-01-18 14:19:41 -06:00
parent 2cd74f9932
commit 2df5dafdaf

View file

@ -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()
}