From 2012e707d022d740d5fd12c6d7fd0cf4f9e272cc Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Thu, 29 Nov 2018 13:31:50 +0300 Subject: [PATCH] Fix race condition of trying to write YAML config simultaneously and failing. --- config.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.go b/config.go index 120d4940..f79923a4 100644 --- a/config.go +++ b/config.go @@ -172,6 +172,8 @@ func parseConfig() error { // Saves configuration to the YAML file and also saves the user filter contents to a file func writeConfig() error { + c.Lock() + defer c.Unlock() configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configFile) yamlText, err := yaml.Marshal(&config)