Commit b6e5ac9c authored by alexstocks's avatar alexstocks

add panic stack info

parent 444d54ed
...@@ -13,6 +13,10 @@ ...@@ -13,6 +13,10 @@
- 2016/09/07 - 2016/09/07
> 1 session.go:(Session)Close() -> session.go:(Session)gc() to be invoked by session.go:(Session)handleLoop > 1 session.go:(Session)Close() -> session.go:(Session)gc() to be invoked by session.go:(Session)handleLoop
>
> 2 add panic stack message for session.go:(Session)handleLoop & session.go:(Session)handlePackage
>
> 3 version: 0.3.05
- 2016/09/06 - 2016/09/06
> 1 codec.go:(Reader)Read(*Session, []byte) (interface{}, error) -> codec.go:(Reader)Read(*Session, []byte) (interface{}, int, error) > 1 codec.go:(Reader)Read(*Session, []byte) (interface{}, error) -> codec.go:(Reader)Read(*Session, []byte) (interface{}, int, error)
......
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
import ( import (
log "github.com/AlexStocks/log4go" log "github.com/AlexStocks/log4go"
"runtime"
) )
const ( const (
...@@ -353,8 +354,12 @@ func (this *Session) handleLoop() { ...@@ -353,8 +354,12 @@ func (this *Session) handleLoop() {
defer func() { defer func() {
var grNum int32 var grNum int32
if err := recover(); err != nil {
log.Error("%s, [session.handleLoop] err=%+v\n", this.sessionToken(), err) if r := recover(); r != nil {
const size = 64 << 10
rBuf := make([]byte, size)
rBuf = rBuf[:runtime.Stack(rBuf, false)]
log.Error("[session.handleLoop] panic session %s: err=%#v\n%s", this.sessionToken(), r, rBuf)
} }
grNum = atomic.AddInt32(&(this.grNum), -1) grNum = atomic.AddInt32(&(this.grNum), -1)
...@@ -433,9 +438,14 @@ func (this *Session) handlePackage() { ...@@ -433,9 +438,14 @@ func (this *Session) handlePackage() {
defer func() { defer func() {
var grNum int32 var grNum int32
if err := recover(); err != nil {
log.Error("%s, [session.handlePackage] = err{%+v}", this.sessionToken(), err) if r := recover(); r != nil {
const size = 64 << 10
rBuf := make([]byte, size)
rBuf = rBuf[:runtime.Stack(rBuf, false)]
log.Error("[session.handlePackage] panic session %s: err=%#v\n%s", this.sessionToken(), r, rBuf)
} }
this.stop() this.stop()
close(this.readerDone) close(this.readerDone)
grNum = atomic.AddInt32(&(this.grNum), -1) grNum = atomic.AddInt32(&(this.grNum), -1)
......
...@@ -10,5 +10,5 @@ ...@@ -10,5 +10,5 @@
package getty package getty
var ( var (
Version = "0.3.04" Version = "0.3.05"
) )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment