Commit a235833b authored by Miek Gieben's avatar Miek Gieben Committed by GitHub

middleware/secondary: pull all zones (#834)

Use the same OnStartup setup as in the file middleware. We need to copy
the variable from range, otherwise it gets overwriten in the next loop
because of the async goroutine call.

Hard to test, we have secondary_test.go which we could extend with
multiple zones for instance. For now this fix does not have an test case
with it...
parent b11cf7c2
...@@ -25,12 +25,13 @@ func setup(c *caddy.Controller) error { ...@@ -25,12 +25,13 @@ func setup(c *caddy.Controller) error {
// Add startup functions to retrieve the zone and keep it up to date. // Add startup functions to retrieve the zone and keep it up to date.
for _, n := range zones.Names { for _, n := range zones.Names {
if len(zones.Z[n].TransferFrom) > 0 { z := zones.Z[n]
if len(z.TransferFrom) > 0 {
c.OnStartup(func() error { c.OnStartup(func() error {
zones.Z[n].StartupOnce.Do(func() { z.StartupOnce.Do(func() {
zones.Z[n].TransferIn() z.TransferIn()
go func() { go func() {
zones.Z[n].Update() z.Update()
}() }()
}) })
return nil return nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment