diff --git a/plugin/file/secondary.go b/plugin/file/secondary.go index 5dcc550fd..6e710a3d0 100644 --- a/plugin/file/secondary.go +++ b/plugin/file/secondary.go @@ -152,9 +152,9 @@ Restart: return nil } soa := z.getSOA() - refresh := time.Second * time.Duration(soa.Refresh) - retry := time.Second * time.Duration(soa.Retry) - expire := time.Second * time.Duration(soa.Expire) + refresh := time.Second * time.Duration(max(soa.Refresh, 1)) + retry := time.Second * time.Duration(max(soa.Retry, 1)) + expire := time.Second * time.Duration(max(soa.Expire, 1)) refreshTicker := time.NewTicker(refresh) retryTicker := time.NewTicker(retry) diff --git a/plugin/file/secondary_test.go b/plugin/file/secondary_test.go index 93ad74e65..3daaf9af3 100644 --- a/plugin/file/secondary_test.go +++ b/plugin/file/secondary_test.go @@ -7,6 +7,7 @@ import ( "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" + "github.com/coredns/coredns/plugin/transfer" "github.com/coredns/coredns/request" "github.com/miekg/dns" @@ -166,3 +167,23 @@ func newRequest(_zone string, _qtype uint16) request.Request { m.SetEdns0(4097, true) return request.Request{W: &test.ResponseWriter{}, Req: m} } + +func TestUpdateWithZeroSOATimers(t *testing.T) { + z := NewZone(testZone, "test") + z.SOA = test.SOA( + fmt.Sprintf("%s IN SOA bla. bla. 1 0 0 0 0", testZone), + ) + + updateShutdown := make(chan bool) + time.AfterFunc(10*time.Millisecond, func() { + close(updateShutdown) + }) + + if err := z.UpdateWithTransfer( + updateShutdown, + nil, + func(*Zone, *transfer.Transfer) error { return nil }, + ); err != nil { + t.Fatalf("Unexpected update error: %v", err) + } +}