mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
优化定时器异常recover
This commit is contained in:
@@ -2,10 +2,10 @@ package timer
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/duanhf2012/origin/log"
|
||||||
"github.com/duanhf2012/origin/util/sync"
|
"github.com/duanhf2012/origin/util/sync"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -90,6 +90,14 @@ type Dispatcher struct {
|
|||||||
|
|
||||||
func (t *Timer) Do(){
|
func (t *Timer) Do(){
|
||||||
if t.cb != nil {
|
if t.cb != nil {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
buf := make([]byte, 4096)
|
||||||
|
l := runtime.Stack(buf, false)
|
||||||
|
err := fmt.Errorf("%v: %s", r, buf[:l])
|
||||||
|
log.Error("core dump info:%+v\n", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
t.cb()
|
t.cb()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user