Skip to content

Commit

Permalink
Merge pull request #138 from cloudflare/brendan/no-crash
Browse files Browse the repository at this point in the history
Catch panics, like net/http.Server.
  • Loading branch information
kisom committed Sep 19, 2016
2 parents 0728b45 + fc583f2 commit 0fb7279
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server/server.go
Expand Up @@ -199,6 +199,12 @@ func (s *Server) handle(conn *gokeyless.Conn) {

func (s *Server) handleReq(conn *gokeyless.Conn, ch chan *gokeyless.Header) {
runtime.LockOSThread()
defer func() {
if err := recover(); err != nil {
log.Errorf("panic while handling request: %v", err)
go s.handleReq(conn, ch)
}
}()

var connError error
for connError == nil {
Expand Down

0 comments on commit 0fb7279

Please sign in to comment.