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

Merge pull request #7 from gunsluo/master

fix recover func
This commit is contained in:
Timothy Ye 2017-04-10 21:34:18 +08:00 committed by GitHub
commit 6f8839ba7b

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 {