Print stack when panic

This commit is contained in:
Asim 2015-12-21 17:18:04 +00:00
parent b9898ef45f
commit 6226a80e78

View File

@ -2,6 +2,7 @@ package server
import ( import (
"fmt" "fmt"
"runtime/debug"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
@ -43,6 +44,13 @@ func newRpcServer(opts ...Option) Server {
} }
func (s *rpcServer) accept(sock transport.Socket) { func (s *rpcServer) accept(sock transport.Socket) {
defer func() {
if r := recover(); r != nil {
log.Error(r, string(debug.Stack()))
sock.Close()
}
}()
var msg transport.Message var msg transport.Message
if err := sock.Recv(&msg); err != nil { if err := sock.Recv(&msg); err != nil {
return return