mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-18 19:43:09 -06:00
More tweaks
This commit is contained in:
parent
6b303ca527
commit
92e138efd0
|
|
@ -4,11 +4,13 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/matrix-org/gomatrix"
|
"github.com/matrix-org/gomatrix"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/federationapi/api"
|
"github.com/matrix-org/dendrite/federationapi/api"
|
||||||
"github.com/matrix-org/dendrite/internal/httputil"
|
"github.com/matrix-org/dendrite/internal/httputil"
|
||||||
|
|
@ -235,7 +237,13 @@ func federationClientError(err error) error {
|
||||||
return &api.FederationClientError{
|
return &api.FederationClientError{
|
||||||
Code: ferr.Code,
|
Code: ferr.Code,
|
||||||
}
|
}
|
||||||
|
case *url.Error: // e.g. certificate error, unable to connect
|
||||||
|
return &api.FederationClientError{
|
||||||
|
Err: ferr.Error(),
|
||||||
|
Code: 400,
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
|
logrus.Debugf("Unknown error: %T", ferr)
|
||||||
return &api.FederationClientError{
|
return &api.FederationClientError{
|
||||||
Err: err.Error(),
|
Err: err.Error(),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -397,11 +397,19 @@ userLoop:
|
||||||
if ctx.Err() != nil {
|
if ctx.Err() != nil {
|
||||||
// we've timed out, give up and go to the back of the queue to let another server be processed.
|
// we've timed out, give up and go to the back of the queue to let another server be processed.
|
||||||
failCount += 1
|
failCount += 1
|
||||||
|
waitTime = time.Minute * 10
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
res, err := u.fedClient.GetUserDevices(ctx, serverName, userID)
|
res, err := u.fedClient.GetUserDevices(ctx, serverName, userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
failCount += 1
|
failCount += 1
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
// we've timed out, give up and go to the back of the queue to let another server be processed.
|
||||||
|
waitTime = time.Minute * 10
|
||||||
|
break userLoop
|
||||||
|
default:
|
||||||
|
}
|
||||||
switch e := err.(type) {
|
switch e := err.(type) {
|
||||||
case *fedsenderapi.FederationClientError:
|
case *fedsenderapi.FederationClientError:
|
||||||
if e.RetryAfter > 0 {
|
if e.RetryAfter > 0 {
|
||||||
|
|
@ -428,7 +436,7 @@ userLoop:
|
||||||
// This is to avoid spamming remote servers, which may not be Matrix servers anymore.
|
// This is to avoid spamming remote servers, which may not be Matrix servers anymore.
|
||||||
if e.Code >= 300 {
|
if e.Code >= 300 {
|
||||||
waitTime = time.Hour
|
waitTime = time.Hour
|
||||||
logrus.WithError(e).Error("GetUserDevices returned gomatrix.HTTPError")
|
logger.WithError(e).Error("GetUserDevices returned gomatrix.HTTPError")
|
||||||
break userLoop
|
break userLoop
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue