mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-11-22 22:31:56 -06:00
Maybe fix concurrent map write
This commit is contained in:
parent
060b54add9
commit
da0dbb8362
|
@ -430,23 +430,28 @@ func (a *KeyInternalAPI) queryRemoteKeys(
|
||||||
|
|
||||||
for result := range resultCh {
|
for result := range resultCh {
|
||||||
for userID, nest := range result.DeviceKeys {
|
for userID, nest := range result.DeviceKeys {
|
||||||
|
respMu.Lock()
|
||||||
res.DeviceKeys[userID] = make(map[string]json.RawMessage)
|
res.DeviceKeys[userID] = make(map[string]json.RawMessage)
|
||||||
|
respMu.Unlock()
|
||||||
for deviceID, deviceKey := range nest {
|
for deviceID, deviceKey := range nest {
|
||||||
keyJSON, err := json.Marshal(deviceKey)
|
keyJSON, err := json.Marshal(deviceKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
respMu.Lock()
|
||||||
res.DeviceKeys[userID][deviceID] = keyJSON
|
res.DeviceKeys[userID][deviceID] = keyJSON
|
||||||
|
respMu.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
respMu.Lock()
|
||||||
for userID, body := range result.MasterKeys {
|
for userID, body := range result.MasterKeys {
|
||||||
res.MasterKeys[userID] = body
|
res.MasterKeys[userID] = body
|
||||||
}
|
}
|
||||||
|
|
||||||
for userID, body := range result.SelfSigningKeys {
|
for userID, body := range result.SelfSigningKeys {
|
||||||
res.SelfSigningKeys[userID] = body
|
res.SelfSigningKeys[userID] = body
|
||||||
}
|
}
|
||||||
|
respMu.Unlock()
|
||||||
|
|
||||||
// TODO: do we want to persist these somewhere now
|
// TODO: do we want to persist these somewhere now
|
||||||
// that we have fetched them?
|
// that we have fetched them?
|
||||||
|
@ -520,7 +525,10 @@ func (a *KeyInternalAPI) queryRemoteKeysOnServer(
|
||||||
resultCh <- &queryKeysResp
|
resultCh <- &queryKeysResp
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
respMu.Lock()
|
respMu.Lock()
|
||||||
|
defer respMu.Unlock()
|
||||||
|
|
||||||
res.Failures[serverName] = map[string]interface{}{
|
res.Failures[serverName] = map[string]interface{}{
|
||||||
"message": err.Error(),
|
"message": err.Error(),
|
||||||
}
|
}
|
||||||
|
@ -537,8 +545,6 @@ func (a *KeyInternalAPI) queryRemoteKeysOnServer(
|
||||||
if len(res.DeviceKeys) > 0 {
|
if len(res.DeviceKeys) > 0 {
|
||||||
delete(res.Failures, serverName)
|
delete(res.Failures, serverName)
|
||||||
}
|
}
|
||||||
respMu.Unlock()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *KeyInternalAPI) populateResponseWithDeviceKeysFromDatabase(
|
func (a *KeyInternalAPI) populateResponseWithDeviceKeysFromDatabase(
|
||||||
|
|
Loading…
Reference in a new issue