From 325acb294250f77c55011b89549f6d43abc1c763 Mon Sep 17 00:00:00 2001 From: "arraykeys@gmail.com" Date: Tue, 9 Oct 2018 14:21:00 +0800 Subject: [PATCH] fix #156 --- core/dst/conn.go | 2 +- core/lib/mapx/map.go | 12 ++++++------ core/lib/udp/udp.go | 8 ++++---- main.go | 2 +- services/socks/socks.go | 2 +- services/tunnel/tunnel_client.go | 12 ++++++------ services/tunnel/tunnel_server.go | 6 +++--- services/udp/udp.go | 12 ++++++------ utils/lb/backend.go | 4 ++-- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/core/dst/conn.go b/core/dst/conn.go index 3a32df7..13d2dae 100644 --- a/core/dst/conn.go +++ b/core/dst/conn.go @@ -137,7 +137,7 @@ func (c *Conn) start() { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s", e, string(debug.Stack())) } }() c.reader() diff --git a/core/lib/mapx/map.go b/core/lib/mapx/map.go index 8d25ffb..3a2f677 100644 --- a/core/lib/mapx/map.go +++ b/core/lib/mapx/map.go @@ -155,7 +155,7 @@ func (m ConcurrentMap) Iter() <-chan Tuple { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s",e, string(debug.Stack())) } }() fanIn(chans, ch) @@ -174,7 +174,7 @@ func (m ConcurrentMap) IterBuffered() <-chan Tuple { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s",e, string(debug.Stack())) } }() fanIn(chans, ch) @@ -195,7 +195,7 @@ func snapshot(m ConcurrentMap) (chans []chan Tuple) { go func(index int, shard *ConcurrentMapShared) { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s",e, string(debug.Stack())) } }() // Foreach key, value pair. @@ -221,7 +221,7 @@ func fanIn(chans []chan Tuple, out chan Tuple) { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s",e, string(debug.Stack())) } }() func(ch chan Tuple) { @@ -274,7 +274,7 @@ func (m ConcurrentMap) Keys() []string { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s",e, string(debug.Stack())) } }() // Foreach shard. @@ -284,7 +284,7 @@ func (m ConcurrentMap) Keys() []string { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s",e, string(debug.Stack())) } }() func(shard *ConcurrentMapShared) { diff --git a/core/lib/udp/udp.go b/core/lib/udp/udp.go index 386ae48..b592a3b 100644 --- a/core/lib/udp/udp.go +++ b/core/lib/udp/udp.go @@ -62,7 +62,7 @@ func (s *IOBinder) AliveWithServeConn(srcAddr string, inTCPConn *net.Conn) *IOBi go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s",e, string(debug.Stack())) } }() buf := make([]byte, 1) @@ -75,7 +75,7 @@ func (s *IOBinder) AliveWithServeConn(srcAddr string, inTCPConn *net.Conn) *IOBi go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s",e, string(debug.Stack())) } }() for { @@ -96,7 +96,7 @@ func (s *IOBinder) AliveWithClientConn(srcAddr string, outTCPConn *net.Conn) *IO go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s",e, string(debug.Stack())) } }() buf := make([]byte, 1) @@ -156,7 +156,7 @@ func (s *IOBinder) Run() (err error) { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s",e, string(debug.Stack())) } }() defer func() { diff --git a/main.go b/main.go index b502e3b..7064501 100644 --- a/main.go +++ b/main.go @@ -36,7 +36,7 @@ func Clean(s *services.Service) { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s", e, string(debug.Stack())) } }() for _ = range signalChan { diff --git a/services/socks/socks.go b/services/socks/socks.go index 5f84431..a0c4a40 100644 --- a/services/socks/socks.go +++ b/services/socks/socks.go @@ -192,7 +192,7 @@ func (s *Socks) InitService() (err error) { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s", e, string(debug.Stack())) } }() //循环检查ssh网络连通性 diff --git a/services/tunnel/tunnel_client.go b/services/tunnel/tunnel_client.go index d43f67e..3787685 100644 --- a/services/tunnel/tunnel_client.go +++ b/services/tunnel/tunnel_client.go @@ -159,7 +159,7 @@ func (s *TunnelClient) Start(args interface{}, log *logger.Logger) (err error) { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s",e, string(debug.Stack())) } }() s.ServeUDP(localAddr, ID, serverID) @@ -168,7 +168,7 @@ func (s *TunnelClient) Start(args interface{}, log *logger.Logger) (err error) { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s",e, string(debug.Stack())) } }() s.ServeConn(localAddr, ID, serverID) @@ -324,7 +324,7 @@ func (s *TunnelClient) ServeUDP(localAddr, ID, serverID string) { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s",e, string(debug.Stack())) } }() (*item).udpConn.Write(body) @@ -335,7 +335,7 @@ func (s *TunnelClient) UDPRevecive(key, ID string) { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s",e, string(debug.Stack())) } }() s.log.Printf("udp conn %s connected", ID) @@ -365,7 +365,7 @@ func (s *TunnelClient) UDPRevecive(key, ID string) { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s",e, string(debug.Stack())) } }() (*cui.conn).SetWriteDeadline(time.Now().Add(time.Millisecond * time.Duration(*s.cfg.Timeout))) @@ -384,7 +384,7 @@ func (s *TunnelClient) UDPGCDeamon() { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s",e, string(debug.Stack())) } }() if s.isStop { diff --git a/services/tunnel/tunnel_server.go b/services/tunnel/tunnel_server.go index 57995a7..f6d13ce 100644 --- a/services/tunnel/tunnel_server.go +++ b/services/tunnel/tunnel_server.go @@ -369,7 +369,7 @@ func (s *TunnelServer) UDPGCDeamon() { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s", e, string(debug.Stack())) } }() if s.isStop { @@ -440,7 +440,7 @@ func (s *TunnelServer) UDPRevecive(key, ID string) { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s", e, string(debug.Stack())) } }() s.log.Printf("udp conn %s connected", ID) @@ -473,7 +473,7 @@ func (s *TunnelServer) UDPRevecive(key, ID string) { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s", e, string(debug.Stack())) } }() s.sc.UDPListener.WriteToUDP(body, uc.srcAddr) diff --git a/services/udp/udp.go b/services/udp/udp.go index b50f885..dbd14af 100644 --- a/services/udp/udp.go +++ b/services/udp/udp.go @@ -174,7 +174,7 @@ func (s *UDP) OutToUDPGCDeamon() { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s", e, string(debug.Stack())) } }() if s.isStop { @@ -216,7 +216,7 @@ func (s *UDP) OutToUDP(packet []byte, localAddr, srcAddr *net.UDPAddr) { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s", e, string(debug.Stack())) } }() s.log.Printf("udp conn %s <--> %s connected", srcAddr.String(), localAddr.String()) @@ -238,7 +238,7 @@ func (s *UDP) OutToUDP(packet []byte, localAddr, srcAddr *net.UDPAddr) { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s", e, string(debug.Stack())) } }() (*(s.sc).UDPListener).SetWriteDeadline(time.Now().Add(time.Millisecond * time.Duration(*s.cfg.Timeout))) @@ -275,7 +275,7 @@ func (s *UDP) UDPGCDeamon() { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s", e, string(debug.Stack())) } }() if s.isStop { @@ -352,7 +352,7 @@ func (s *UDP) UDPRevecive(key string) { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s", e, string(debug.Stack())) } }() s.log.Printf("udp conn %s connected", key) @@ -385,7 +385,7 @@ func (s *UDP) UDPRevecive(key string) { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s", e, string(debug.Stack())) } }() s.sc.UDPListener.WriteToUDP(body, uc.srcAddr) diff --git a/utils/lb/backend.go b/utils/lb/backend.go index 90678cd..ff24e88 100644 --- a/utils/lb/backend.go +++ b/utils/lb/backend.go @@ -116,7 +116,7 @@ func (b *Backend) startMuxHeartCheck() { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s",e, string(debug.Stack())) } }() for { @@ -151,7 +151,7 @@ func (b *Backend) startTCPHeartCheck() { go func() { defer func() { if e := recover(); e != nil { - fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack())) + fmt.Printf("crashed, err: %s\nstack:\n%s",e, string(debug.Stack())) } }() for {