From 0ce88036aa79b0ce97e967afb70fe932a547d5f0 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 13 Apr 2021 10:01:07 +0100 Subject: [PATCH] Guard processEventWithMissingState instead --- federationapi/routing/send.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/federationapi/routing/send.go b/federationapi/routing/send.go index 708ba38ec..6034dc558 100644 --- a/federationapi/routing/send.go +++ b/federationapi/routing/send.go @@ -621,6 +621,8 @@ func checkAllowedByState(e *gomatrixserverlib.Event, stateEvents []*gomatrixserv func (t *txnReq) processEventWithMissingState( ctx context.Context, e *gomatrixserverlib.Event, roomVersion gomatrixserverlib.RoomVersion, ) error { + t.roomsMu.Lock(e.RoomID()) + defer t.roomsMu.Unlock(e.RoomID()) // 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 // side retries, we'll have fetched the missing state. @@ -716,9 +718,7 @@ func (t *txnReq) processEventWithMissingState( respStates[i] = states[i].RespState } // There's more than one previous state - run them all through state res - t.roomsMu.Lock(e.RoomID()) resolvedState, err = t.resolveStatesAndCheck(gmectx, roomVersion, respStates, backwardsExtremity) - t.roomsMu.Unlock(e.RoomID()) if err != nil { util.GetLogger(ctx).WithError(err).Errorf("Failed to resolve state conflicts for event %s", backwardsExtremity.EventID()) return err