Increase timeouts for testing, observe contexts before trying to join over more servers

This commit is contained in:
Neil Alexander 2020-04-20 10:54:45 +01:00
parent 23896d6aa8
commit 029e750e1e
3 changed files with 18 additions and 8 deletions

View file

@ -16,7 +16,6 @@ package producers
import ( import (
"context" "context"
"fmt"
"github.com/matrix-org/dendrite/roomserver/api" "github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/gomatrixserverlib"
@ -64,11 +63,6 @@ func (c *RoomserverProducer) SendEventWithState(
return err return err
} }
fmt.Println("OUTLIERS")
for _, v := range outliers {
fmt.Println("*", v.EventID(), v.Type())
}
var ires []api.InputRoomEvent var ires []api.InputRoomEvent
for _, outlier := range outliers { for _, outlier := range outliers {
ires = append(ires, api.InputRoomEvent{ ires = append(ires, api.InputRoomEvent{

View file

@ -290,7 +290,15 @@ func (r joinRoomReq) joinRoomUsingServers(
// There was a problem talking to one of the servers. // There was a problem talking to one of the servers.
util.GetLogger(r.req.Context()).WithError(lastErr).WithField("server", server).Warn("Failed to join room using server") util.GetLogger(r.req.Context()).WithError(lastErr).WithField("server", server).Warn("Failed to join room using server")
// Try the next server. // Try the next server.
continue if r.req.Context().Err() != nil {
// The request context has expired so don't bother trying any
// more servers - they will immediately fail due to the expired
// context.
break
} else {
// The request context hasn't expired yet so try the next server.
continue
}
} }
return *response return *response
} }

View file

@ -17,6 +17,7 @@ package main
import ( import (
"flag" "flag"
"net/http" "net/http"
"time"
"github.com/matrix-org/dendrite/appservice" "github.com/matrix-org/dendrite/appservice"
"github.com/matrix-org/dendrite/clientapi" "github.com/matrix-org/dendrite/clientapi"
@ -91,7 +92,14 @@ func main() {
// Expose the matrix APIs directly rather than putting them under a /api path. // Expose the matrix APIs directly rather than putting them under a /api path.
go func() { go func() {
logrus.Info("Listening on ", *httpBindAddr) logrus.Info("Listening on ", *httpBindAddr)
logrus.Fatal(http.ListenAndServe(*httpBindAddr, nil)) serv := http.Server{
Addr: *httpBindAddr,
ReadTimeout: time.Second * 300,
ReadHeaderTimeout: time.Second * 300,
WriteTimeout: time.Second * 300,
IdleTimeout: time.Second * 300,
}
logrus.Fatal(serv.ListenAndServe())
}() }()
// Handle HTTPS if certificate and key are provided // Handle HTTPS if certificate and key are provided
go func() { go func() {