1
0
mirror of https://github.com/taigrr/godns synced 2025-01-18 04:03:25 -08:00

fix recover func

Signed-off-by: jerrylou <gunsluo@gmail.com>
This commit is contained in:
jerrylou 2017-04-10 20:31:30 +08:00
parent 5f5243f66e
commit d9a76d42fc

View File

@ -70,18 +70,6 @@ func main() {
}
func dnsLoop() {
defer func() {
if err := recover(); err != nil {
panicCount++
log.Printf("Recovered in %v: %v\n", err, debug.Stack())
fmt.Println(identifyPanic())
log.Print(identifyPanic())
if panicCount < PANIC_MAX {
log.Println("Got panic in goroutine, will start a new one... :", panicCount)
go dnsLoop()
}
}
}()
for _, domain := range configuration.Domains {
go DomainLoop(&domain)
@ -91,6 +79,20 @@ func dnsLoop() {
}
func DomainLoop(domain *Domain) {
defer func() {
if err := recover(); err != nil {
panicCount++
log.Printf("Recovered in %v: %v\n", err, debug.Stack())
fmt.Println(identifyPanic())
log.Print(identifyPanic())
if panicCount < PANIC_MAX {
log.Println("Got panic in goroutine, will start a new one... :", panicCount)
go DomainLoop(domain)
} else {
os.Exit(1)
}
}
}()
for {