aboutsummaryrefslogtreecommitdiff
path: root/federationapi/routing/send.go
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2021-06-30 10:39:47 +0100
committerGitHub <noreply@github.com>2021-06-30 10:39:47 +0100
commit0e69212206d7abbe5d3e4c65b4ae369a0067bdc9 (patch)
tree2ac4e52543c9a039730d11b4f394b008d5c185a6 /federationapi/routing/send.go
parent3afb1613522891e68a8c2f21807bb83762c4122f (diff)
Give up on loops when the context expires (#1891)
Diffstat (limited to 'federationapi/routing/send.go')
-rw-r--r--federationapi/routing/send.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/federationapi/routing/send.go b/federationapi/routing/send.go
index 06a38b9c..032c0c3b 100644
--- a/federationapi/routing/send.go
+++ b/federationapi/routing/send.go
@@ -18,6 +18,7 @@ import (
"context"
"database/sql"
"encoding/json"
+ "errors"
"fmt"
"net/http"
"sync"
@@ -570,6 +571,9 @@ withNextEvent:
tx, err := t.federation.GetEvent(ctx, server, missingAuthEventID)
if err != nil {
logger.WithError(err).Warnf("Failed to retrieve auth event %q", missingAuthEventID)
+ if errors.Is(err, context.DeadlineExceeded) {
+ return err
+ }
continue withNextServer
}
ev, err := gomatrixserverlib.NewEventFromUntrustedJSON(tx.PDUs[0], stateResp.RoomVersion)
@@ -958,6 +962,9 @@ func (t *txnReq) getMissingEvents(ctx context.Context, e *gomatrixserverlib.Even
break
} else {
logger.WithError(err).Errorf("%s pushed us an event but %q did not respond to /get_missing_events", t.Origin, server)
+ if errors.Is(err, context.DeadlineExceeded) {
+ break
+ }
}
}
@@ -1218,6 +1225,9 @@ func (t *txnReq) lookupEvent(ctx context.Context, roomVersion gomatrixserverlib.
txn, err := t.federation.GetEvent(ctx, serverName, missingEventID)
if err != nil || len(txn.PDUs) == 0 {
util.GetLogger(ctx).WithError(err).WithField("event_id", missingEventID).Warn("Failed to get missing /event for event ID")
+ if errors.Is(err, context.DeadlineExceeded) {
+ break
+ }
continue
}
event, err = gomatrixserverlib.NewEventFromUntrustedJSON(txn.PDUs[0], roomVersion)