Don't share sync.Once with all directives

If each server block had only one sync.Once then all directives would refer to it and only the first directive would be able to use it! So this commit changes it to a map of sync.Once instances, keyed by directive. So by creating a new map for every server block, each directive in that block can get its own sync.Once which is exactly what is needed. They won't step on each other this way.
This commit is contained in:
Matthew Holt
2015-10-15 00:07:26 -06:00
parent 0c07f7adcc
commit e0fdddc73f
2 changed files with 25 additions and 3 deletions
+6 -1
View File
@@ -11,10 +11,15 @@ import (
)
// Controller is given to the setup function of middlewares which
// gives them access to be able to read tokens and set config.
// gives them access to be able to read tokens and set config. Each
// virtualhost gets their own server config and dispenser.
type Controller struct {
*server.Config
parse.Dispenser
// OncePerServerBlock is a function that executes f
// exactly once per server block, no matter how many
// hosts are associated with it.
OncePerServerBlock func(f func())
}