mirror of
https://github.com/coredns/coredns.git
synced 2025-11-22 11:52:17 -05:00
fix: fix reload causing secondary plugin goroutine to leak. (#7694)
Signed-off-by: wenxuan70 <t736660416@gmail.com>
This commit is contained in:
@@ -107,7 +107,7 @@ func less(a, b uint32) bool {
|
|||||||
// and uses the SOA parameters. Every refresh it will check for a new SOA number. If that fails (for all
|
// and uses the SOA parameters. Every refresh it will check for a new SOA number. If that fails (for all
|
||||||
// server) it will retry every retry interval. If the zone failed to transfer before the expire, the zone
|
// server) it will retry every retry interval. If the zone failed to transfer before the expire, the zone
|
||||||
// will be marked expired.
|
// will be marked expired.
|
||||||
func (z *Zone) Update() error {
|
func (z *Zone) Update(updateShutdown chan bool) error {
|
||||||
// If we don't have a SOA, we don't have a zone, wait for it to appear.
|
// If we don't have a SOA, we don't have a zone, wait for it to appear.
|
||||||
for z.SOA == nil {
|
for z.SOA == nil {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
@@ -183,6 +183,12 @@ Restart:
|
|||||||
retryTicker.Stop()
|
retryTicker.Stop()
|
||||||
expireTicker.Stop()
|
expireTicker.Stop()
|
||||||
goto Restart
|
goto Restart
|
||||||
|
|
||||||
|
case <-updateShutdown:
|
||||||
|
refreshTicker.Stop()
|
||||||
|
retryTicker.Stop()
|
||||||
|
expireTicker.Stop()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ func setup(c *caddy.Controller) error {
|
|||||||
n := zones.Names[i]
|
n := zones.Names[i]
|
||||||
z := zones.Z[n]
|
z := zones.Z[n]
|
||||||
if len(z.TransferFrom) > 0 {
|
if len(z.TransferFrom) > 0 {
|
||||||
|
// In order to support secondary plugin reloading.
|
||||||
|
updateShutdown := make(chan bool)
|
||||||
|
|
||||||
c.OnStartup(func() error {
|
c.OnStartup(func() error {
|
||||||
z.StartupOnce.Do(func() {
|
z.StartupOnce.Do(func() {
|
||||||
go func() {
|
go func() {
|
||||||
@@ -43,12 +46,21 @@ func setup(c *caddy.Controller) error {
|
|||||||
if dur > max {
|
if dur > max {
|
||||||
dur = max
|
dur = max
|
||||||
}
|
}
|
||||||
|
select {
|
||||||
|
case <-updateShutdown:
|
||||||
|
return
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
z.Update()
|
}
|
||||||
|
z.Update(updateShutdown)
|
||||||
}()
|
}()
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
c.OnShutdown(func() error {
|
||||||
|
updateShutdown <- true
|
||||||
|
return nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user