Skip to content

Commit cc50483

Browse files
committed
dnsx/cacher: a panic appears... for testing in prod
1 parent e60340e commit cc50483

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

intra/dnsx/cacher.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
x "github.com/celzero/firestack/intra/backend"
1919
"github.com/celzero/firestack/intra/core"
2020
"github.com/celzero/firestack/intra/log"
21+
"github.com/celzero/firestack/intra/settings"
2122
"github.com/celzero/firestack/intra/xdns"
2223
"github.com/miekg/dns"
2324
)
@@ -316,7 +317,9 @@ func (t *ctransport) hangoverCheckpoint() {
316317

317318
func (t *ctransport) fetch(network string, q *dns.Msg, summary *x.DNSSummary, cb *cache, key string) (*dns.Msg, error) {
318319
sendRequest := func(fsmm *x.DNSSummary) (*dns.Msg, error) {
319-
defer core.Recover(core.DontExit, "c.sendRequest: "+t.ID()+t.Type())
320+
if settings.Debug && rand10pc() {
321+
panic("test crash")
322+
}
320323

321324
fsmm.ID = t.ID()
322325
fsmm.Type = t.Type()
@@ -391,9 +394,9 @@ func (t *ctransport) fetch(network string, q *dns.Msg, summary *x.DNSSummary, cb
391394
// fallthrough to sendRequest
392395
} else if cachedsummary != nil {
393396
if !isfresh { // not fresh, fetch in the background
394-
go func() {
397+
core.Go("c.sendRequest: "+t.ID()+t.Type(), func() {
395398
_, _ = sendRequest(new(x.DNSSummary))
396-
}()
399+
})
397400
}
398401
// change summary fields to reflect cached response, except for latency
399402
fillSummary(cachedsummary, summary)
@@ -496,3 +499,7 @@ func fillSummary(s *x.DNSSummary, other *x.DNSSummary) {
496499
func rand33pc() bool {
497500
return rand.Intn(99999) < 33000
498501
}
502+
503+
func rand10pc() bool {
504+
return rand.Intn(99999) < 10000
505+
}

0 commit comments

Comments
 (0)