Make default api listen address configurable, fix race conditions

This commit is contained in:
Daniel 2019-05-22 16:12:44 +02:00
parent bbf06b31ac
commit 60dbbe55e9
3 changed files with 21 additions and 11 deletions

View file

@ -367,7 +367,10 @@ func (api *DatabaseAPI) processSub(opID []byte, sub *database.Subscription) {
continue
}
// TODO: use upd, new and delete msgTypes
if r.Meta().IsDeleted() {
r.Lock()
isDeleted := r.Meta().IsDeleted()
r.Unlock()
if isDeleted {
api.send(opID, dbMsgTypeDel, r.Key(), nil)
} else {
api.send(opID, dbMsgTypeUpd, r.Key(), data)