Skip to content

Commit

Permalink
settings: Make Un-/MarshalJSON thread safe
Browse files Browse the repository at this point in the history
  • Loading branch information
quarnster committed Sep 26, 2015
1 parent d3174ab commit 0af0865
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ func (s *Settings) Parent() SettingsInterface {
}

func (s *Settings) UnmarshalJSON(data []byte) error {
s.lock.Lock()
defer s.lock.Unlock()
return json.Unmarshal(data, &s.data)
}

func (s *Settings) MarshalJSON() (data []byte, err error) {
s.lock.Lock()
defer s.lock.Unlock()
return json.Marshal(&s.data)
}

Expand Down

0 comments on commit 0af0865

Please sign in to comment.