Skip to content

Commit

Permalink
updateConfig now uses sync.Mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
tierpod committed Apr 10, 2018
1 parent bc81340 commit 784147f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/sd-dbus-hooks/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"io/ioutil"
"sync"

"gopkg.in/yaml.v2"
)
Expand All @@ -20,6 +21,7 @@ const (

var (
sdStatesAll = []string{sdStateActive, sdStateActivating, sdStateInactive, sdStateDeactivating, sdStateFailed, sdStateReloading}
configLock = new(sync.Mutex)
)

// Config contains service configuration
Expand Down Expand Up @@ -93,6 +95,8 @@ func updateConfig(cfg *Config, path string) error {
return err
}

configLock.Lock()
defer configLock.Unlock()
*cfg = c
return nil
}

0 comments on commit 784147f

Please sign in to comment.