Skip to content

Commit

Permalink
Wrap goroutines in HandleCrash()
Browse files Browse the repository at this point in the history
  • Loading branch information
thockin committed Sep 12, 2014
1 parent 1e50f11 commit 3181f35
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/proxy/proxier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 3181f35

Please sign in to comment.