From 3181f3555d3503336a23994b9e81c7375cc27ad8 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Thu, 11 Sep 2014 16:21:00 -0700 Subject: [PATCH] Wrap goroutines in HandleCrash() --- pkg/proxy/proxier.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/proxy/proxier.go b/pkg/proxy/proxier.go index 7d5f48cb5fa..42e2bb760d5 100644 --- a/pkg/proxy/proxier.go +++ b/pkg/proxy/proxier.go @@ -213,7 +213,10 @@ func (udp *udpProxySocket) getBackendConn(activeClients *clientCache, cliAddr ne return nil, err } activeClients.clients[cliAddr.String()] = svrConn - go udp.proxyClient(cliAddr, svrConn, activeClients, timeout) + go func(cliAddr net.Addr, svrConn net.Conn, activeClients *clientCache, timeout time.Duration) { + defer util.HandleCrash() + udp.proxyClient(cliAddr, svrConn, activeClients, timeout) + }(cliAddr, svrConn, activeClients, timeout) } return svrConn, nil } @@ -375,7 +378,10 @@ func (proxier *Proxier) addServiceOnUnusedPort(service, protocol string, timeout func (proxier *Proxier) startAccepting(service string, sock proxySocket) { glog.Infof("Listening for %s on %s:%s", service, sock.Addr().Network(), sock.Addr().String()) - go sock.ProxyLoop(service, proxier) + go func(service string, proxier *Proxier) { + defer util.HandleCrash() + sock.ProxyLoop(service, proxier) + }(service, proxier) } // How long we leave idle UDP connections open.