diff --git a/clientapi/routing/register.go b/clientapi/routing/register.go index 6827bed22..8faff58f8 100644 --- a/clientapi/routing/register.go +++ b/clientapi/routing/register.go @@ -156,6 +156,13 @@ func (d *sessionsDict) startTimer(duration time.Duration, sessionID string) { }) } +func (d *sessionsDict) hasSession(sessionID string) bool { + d.RLock() + defer d.RUnlock() + _, ok := d.sessions[sessionID] + return ok +} + // addCompletedSessionStage records that a session has completed an auth stage // also starts a timer to delete the session once done. func (d *sessionsDict) addCompletedSessionStage(sessionID string, stage authtypes.LoginType) { diff --git a/clientapi/routing/register_publickey.go b/clientapi/routing/register_publickey.go index 258a47249..f5c972bb1 100644 --- a/clientapi/routing/register_publickey.go +++ b/clientapi/routing/register_publickey.go @@ -62,7 +62,7 @@ func handlePublicKeyRegistration( return false, authtypes.LoginStagePublicKeyNewRegistration, nil } - if _, ok := sessions.sessions[authHandler.GetSession()]; !ok { + if !sessions.hasSession(authHandler.GetSession()) { return false, "", &util.JSONResponse{ Code: http.StatusUnauthorized, JSON: jsonerror.Unknown("the session ID is missing or unknown."), diff --git a/roomserver/internal/perform/perform_backfill.go b/roomserver/internal/perform/perform_backfill.go index 57e121ea2..7d65c44fb 100644 --- a/roomserver/internal/perform/perform_backfill.go +++ b/roomserver/internal/perform/perform_backfill.go @@ -18,6 +18,7 @@ import ( "context" "fmt" + "github.com/getsentry/sentry-go" "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/util" "github.com/sirupsen/logrus" @@ -322,6 +323,7 @@ FederationHit: b.eventIDToBeforeStateIDs[targetEvent.EventID()] = res return res, nil } + sentry.CaptureException(lastErr) // temporary to see if we might need to raise the server limit return nil, lastErr }