Fix race condition of trying to write YAML config simultaneously and failing.

This commit is contained in:
Eugene Bujak 2018-11-29 13:31:50 +03:00
parent 942cde79bd
commit 2012e707d0
1 changed files with 2 additions and 0 deletions

View File

@ -172,6 +172,8 @@ func parseConfig() error {
// Saves configuration to the YAML file and also saves the user filter contents to a file // Saves configuration to the YAML file and also saves the user filter contents to a file
func writeConfig() error { func writeConfig() error {
c.Lock()
defer c.Unlock()
configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename)
log.Printf("Writing YAML file: %s", configFile) log.Printf("Writing YAML file: %s", configFile)
yamlText, err := yaml.Marshal(&config) yamlText, err := yaml.Marshal(&config)