mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-11-22 22:31:56 -06:00
Fix lock contention
This commit is contained in:
parent
c1463db6c9
commit
8cbe14bd6d
|
@ -542,9 +542,7 @@ func (a *KeyInternalAPI) queryRemoteKeysOnServer(
|
||||||
}
|
}
|
||||||
// refresh entries from DB: unlike remoteKeysFromDatabase we know we previously had no device info for this
|
// refresh entries from DB: unlike remoteKeysFromDatabase we know we previously had no device info for this
|
||||||
// user so the fact that we're populating all devices here isn't a problem so long as we have devices.
|
// user so the fact that we're populating all devices here isn't a problem so long as we have devices.
|
||||||
respMu.Lock()
|
|
||||||
err = a.populateResponseWithDeviceKeysFromDatabase(ctx, res, respMu, userID, nil)
|
err = a.populateResponseWithDeviceKeysFromDatabase(ctx, res, respMu, userID, nil)
|
||||||
respMu.Unlock()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
logrus.ErrorKey: err,
|
logrus.ErrorKey: err,
|
||||||
|
@ -568,6 +566,7 @@ func (a *KeyInternalAPI) queryRemoteKeysOnServer(
|
||||||
res.Failures[serverName] = map[string]interface{}{
|
res.Failures[serverName] = map[string]interface{}{
|
||||||
"message": err.Error(),
|
"message": err.Error(),
|
||||||
}
|
}
|
||||||
|
respMu.Unlock()
|
||||||
|
|
||||||
// last ditch, use the cache only. This is good for when clients hit /keys/query and the remote server
|
// last ditch, use the cache only. This is good for when clients hit /keys/query and the remote server
|
||||||
// is down, better to return something than nothing at all. Clients can know about the failure by
|
// is down, better to return something than nothing at all. Clients can know about the failure by
|
||||||
|
@ -578,11 +577,11 @@ func (a *KeyInternalAPI) queryRemoteKeysOnServer(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sytest expects no failures, if we still could retrieve keys, e.g. from local cache
|
// Sytest expects no failures, if we still could retrieve keys, e.g. from local cache
|
||||||
|
respMu.Lock()
|
||||||
if len(res.DeviceKeys) > 0 {
|
if len(res.DeviceKeys) > 0 {
|
||||||
delete(res.Failures, serverName)
|
delete(res.Failures, serverName)
|
||||||
}
|
}
|
||||||
respMu.Unlock()
|
respMu.Unlock()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *KeyInternalAPI) populateResponseWithDeviceKeysFromDatabase(
|
func (a *KeyInternalAPI) populateResponseWithDeviceKeysFromDatabase(
|
||||||
|
|
Loading…
Reference in a new issue