Only transfer a zone once (#117)

Use sync.Once to only transfer a zone once.

Fixes #115
This commit is contained in:
Miek Gieben
2016-04-13 20:14:03 +01:00
parent 5a8a125399
commit 982377516b
3 changed files with 17 additions and 12 deletions

View File

@@ -17,13 +17,12 @@ func Secondary(c *Controller) (middleware.Middleware, error) {
for _, n := range zones.Names {
if len(zones.Z[n].TransferFrom) > 0 {
c.Startup = append(c.Startup, func() error {
err := zones.Z[n].TransferIn()
return err
})
c.Startup = append(c.Startup, func() error {
go func() {
zones.Z[n].Update()
}()
zones.Z[n].StartupOnce.Do(func() {
zones.Z[n].TransferIn()
go func() {
zones.Z[n].Update()
}()
})
return nil
})
}