Skip to content

Commit dcef155

Browse files
committed
some more locks
1 parent b73763c commit dcef155

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

application/backend/app/containerdb/containerdb.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,14 @@ func PutLogMessage(db *leveldb.DB, host string, container string, message_item [
251251
MaybeScheduleCleanup(host, container)
252252

253253
location := host + "/" + container
254+
status_key := GetLogStatusKey(message_item[1])
255+
vars.Mutex.Lock()
254256
if vars.Statuses_DBs[location] == nil {
255257
vars.Statuses_DBs[location] = util.GetDB(host, container, "statuses")
256258
}
257-
status_key := GetLogStatusKey(message_item[1])
258-
vars.Mutex.Lock()
259259
vars.Container_Stat_Counter[location][status_key]++
260-
vars.Mutex.Unlock()
261260
vars.Statuses_DBs[location].Put([]byte(message_item[0]), []byte(status_key), nil)
261+
vars.Mutex.Unlock()
262262

263263
err := db.Put([]byte(message_item[0]), []byte(message_item[1]), nil)
264264
tries := 0

application/backend/app/userdb/userdb.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,7 @@ func UpdateUserSettings(username string, settings map[string]interface{}) {
7474
settingsDB, _ := leveldb.OpenFile("leveldb/usersSettings", nil)
7575
defer settingsDB.Close()
7676
to_put, _ := json.Marshal(settings)
77+
vars.Mutex.Lock()
7778
settingsDB.Put([]byte(username), to_put, nil)
79+
vars.Mutex.Unlock()
7880
}

0 commit comments

Comments
 (0)