From 17a4d0447632580c46fe7bd46b54dd82dcca012b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Tikvi=C4=87?= Date: Mon, 28 Nov 2016 09:57:12 +0100 Subject: [PATCH] mutex lock for payloads --- json_utility.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/json_utility.go b/json_utility.go index b5a3aa9..5ce4f01 100644 --- a/json_utility.go +++ b/json_utility.go @@ -7,8 +7,10 @@ import ( "gopkg.in/rana/ora.v3" "io" "io/ioutil" + "sync" ) +var mu = &sync.Mutex{} var allPayloads []payloadBuff type LangMap map[string]map[string]string @@ -134,6 +136,8 @@ func loadCorrelations(id string) []CorrelationField { func InitTables(db *ora.Ses, project string) error { jsonbuf, _ := fetchJSON(db, EqualQuotes(project)) + mu.Lock() + defer mu.Unlock() json.Unmarshal(jsonbuf, &allPayloads) if len(allPayloads) == 0 { return errors.New("tables config is corrupt") -- 1.8.1.2