From b4fb62b577e8bbd46e874dc036b323475accd71e Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 13 Apr 2021 09:56:31 +0100 Subject: [PATCH] Move room mutex in federation API to surround resolveStatesAndCheck --- 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 fee6d565f..708ba38ec 100644 --- a/federationapi/routing/send.go +++ b/federationapi/routing/send.go @@ -498,8 +498,6 @@ func (t *txnReq) getServers(ctx context.Context, roomID string) []gomatrixserver } func (t *txnReq) processEvent(ctx context.Context, e *gomatrixserverlib.Event) error { - t.roomsMu.Lock(e.RoomID()) - defer t.roomsMu.Unlock(e.RoomID()) logger := util.GetLogger(ctx).WithField("event_id", e.EventID()).WithField("room_id", e.RoomID()) t.work = "" // reset from previous event @@ -718,7 +716,9 @@ 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