Commit 17a4d0447632580c46fe7bd46b54dd82dcca012b

Authored by Marko Tikvić
1 parent 3b2c2699fe
Exists in master and in 1 other branch v2

mutex lock for payloads

Showing 1 changed file with 4 additions and 0 deletions   Show diff stats
... ... @@ -7,8 +7,10 @@ import (
7 7 "gopkg.in/rana/ora.v3"
8 8 "io"
9 9 "io/ioutil"
  10 + "sync"
10 11 )
11 12  
  13 +var mu = &sync.Mutex{}
12 14 var allPayloads []payloadBuff
13 15  
14 16 type LangMap map[string]map[string]string
... ... @@ -134,6 +136,8 @@ func loadCorrelations(id string) []CorrelationField {
134 136  
135 137 func InitTables(db *ora.Ses, project string) error {
136 138 jsonbuf, _ := fetchJSON(db, EqualQuotes(project))
  139 + mu.Lock()
  140 + defer mu.Unlock()
137 141 json.Unmarshal(jsonbuf, &allPayloads)
138 142 if len(allPayloads) == 0 {
139 143 return errors.New("tables config is corrupt")
... ...