mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 07:28:27 +00:00
Use internal.MutexByRoom
This commit is contained in:
parent
6e6f026cfa
commit
138cddcac7
1 changed files with 3 additions and 8 deletions
|
@ -620,18 +620,13 @@ func checkAllowedByState(e *gomatrixserverlib.Event, stateEvents []*gomatrixserv
|
||||||
return gomatrixserverlib.Allowed(e, &authUsingState)
|
return gomatrixserverlib.Allowed(e, &authUsingState)
|
||||||
}
|
}
|
||||||
|
|
||||||
var processEventWithMissingStateMutexes = map[string]*sync.Mutex{}
|
var processEventWithMissingStateMutexes = &internal.MutexByRoom{}
|
||||||
|
|
||||||
func (t *txnReq) processEventWithMissingState(
|
func (t *txnReq) processEventWithMissingState(
|
||||||
ctx context.Context, e *gomatrixserverlib.Event, roomVersion gomatrixserverlib.RoomVersion,
|
ctx context.Context, e *gomatrixserverlib.Event, roomVersion gomatrixserverlib.RoomVersion,
|
||||||
) error {
|
) error {
|
||||||
mu, ok := processEventWithMissingStateMutexes[e.RoomID()]
|
processEventWithMissingStateMutexes.Lock(e.RoomID())
|
||||||
if !ok {
|
defer processEventWithMissingStateMutexes.Unlock(e.RoomID())
|
||||||
processEventWithMissingStateMutexes[e.RoomID()] = &sync.Mutex{}
|
|
||||||
mu = processEventWithMissingStateMutexes[e.RoomID()]
|
|
||||||
}
|
|
||||||
mu.Lock()
|
|
||||||
defer mu.Unlock()
|
|
||||||
|
|
||||||
// Do this with a fresh context, so that we keep working even if the
|
// Do this with a fresh context, so that we keep working even if the
|
||||||
// original request times out. With any luck, by the time the remote
|
// original request times out. With any luck, by the time the remote
|
||||||
|
|
Loading…
Reference in a new issue