mirror of
https://github.com/oneclickvirt/backtrace.git
synced 2026-11-24 23:39:41 +08:00
fix:修复panic恢复机制
This commit is contained in:
1 parent
026f9784e4
commit
ce8555f149
11 files changed
+94
-21
No files matched your search
+20
-3
@@ -7,6 +7,14 @@ import (
|
||||
"github.com/oneclickvirt/backtrace/model"
|
||||
)
|
||||
|
||||
func safeTraceCall(fn func()) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
}
|
||||
}()
|
||||
fn()
|
||||
}
|
||||
|
||||
func BackTrace(enableIpv6 bool) string {
|
||||
if model.CachedIcmpData == "" || model.ParsedIcmpTargets == nil || time.Since(model.CachedIcmpDataFetchTime) > time.Hour {
|
||||
model.CachedIcmpData = getData(model.IcmpTargets)
|
||||
@@ -26,10 +34,16 @@ func BackTrace(enableIpv6 bool) string {
|
||||
t = time.After(time.Second * 10)
|
||||
)
|
||||
for i := range model.Ipv4s {
|
||||
go trace(c, i)
|
||||
idx := i
|
||||
go safeTraceCall(func() {
|
||||
trace(c, idx)
|
||||
})
|
||||
}
|
||||
for i := range model.Ipv6s {
|
||||
go traceIPv6(c, i, ipv4Count)
|
||||
idx := i
|
||||
go safeTraceCall(func() {
|
||||
traceIPv6(c, idx, ipv4Count)
|
||||
})
|
||||
}
|
||||
loopIPv4v6:
|
||||
for range s {
|
||||
@@ -62,7 +76,10 @@ func BackTrace(enableIpv6 bool) string {
|
||||
t = time.After(time.Second * 10)
|
||||
)
|
||||
for i := range model.Ipv4s {
|
||||
go trace(c, i)
|
||||
idx := i
|
||||
go safeTraceCall(func() {
|
||||
trace(c, idx)
|
||||
})
|
||||
}
|
||||
loopIPv4:
|
||||
for range s {
|
||||
|
||||
Reference in new issue
Block a user