mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 07:28:27 +00:00
Try to slow things down per room
This commit is contained in:
parent
b97d406dff
commit
6e6f026cfa
1 changed files with 8 additions and 3 deletions
|
@ -620,13 +620,18 @@ func checkAllowedByState(e *gomatrixserverlib.Event, stateEvents []*gomatrixserv
|
|||
return gomatrixserverlib.Allowed(e, &authUsingState)
|
||||
}
|
||||
|
||||
var processEventWithMissingStateMutex sync.Mutex
|
||||
var processEventWithMissingStateMutexes = map[string]*sync.Mutex{}
|
||||
|
||||
func (t *txnReq) processEventWithMissingState(
|
||||
ctx context.Context, e *gomatrixserverlib.Event, roomVersion gomatrixserverlib.RoomVersion,
|
||||
) error {
|
||||
processEventWithMissingStateMutex.Lock()
|
||||
defer processEventWithMissingStateMutex.Unlock()
|
||||
mu, ok := processEventWithMissingStateMutexes[e.RoomID()]
|
||||
if !ok {
|
||||
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
|
||||
// original request times out. With any luck, by the time the remote
|
||||
|
|
Loading…
Reference in a new issue