Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provider/template: fix race causing panic in template_file
The render code path in `template_file` was doing unsynchronized access to a shared mapping of functions in `config.Func`. This caused a race condition that was most often triggered when a `template_file` had a `count` of more than one, and expressed itself as a panic in the plugin followed by a cascade of "unexpected EOF" errors through the plugin system. Here, we simply turn the FuncMap from shared state into a generated value, which avoids the race. We do more re-initialization of the data structure, but the performance implications are minimal, and we can always revisit with a perf pass later now that the race is fixed.
- Loading branch information