diff --git a/clientapi/producers/roomserver.go b/clientapi/producers/roomserver.go index f881fda57..391ea07bf 100644 --- a/clientapi/producers/roomserver.go +++ b/clientapi/producers/roomserver.go @@ -16,7 +16,6 @@ package producers import ( "context" - "fmt" "github.com/matrix-org/dendrite/roomserver/api" "github.com/matrix-org/gomatrixserverlib" @@ -64,11 +63,6 @@ func (c *RoomserverProducer) SendEventWithState( return err } - fmt.Println("OUTLIERS") - for _, v := range outliers { - fmt.Println("*", v.EventID(), v.Type()) - } - var ires []api.InputRoomEvent for _, outlier := range outliers { ires = append(ires, api.InputRoomEvent{ diff --git a/clientapi/routing/joinroom.go b/clientapi/routing/joinroom.go index 06f98351c..024e97e99 100644 --- a/clientapi/routing/joinroom.go +++ b/clientapi/routing/joinroom.go @@ -290,7 +290,15 @@ func (r joinRoomReq) joinRoomUsingServers( // 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") // 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 } diff --git a/cmd/dendrite-monolith-server/main.go b/cmd/dendrite-monolith-server/main.go index d47d2e1bb..603fc954a 100644 --- a/cmd/dendrite-monolith-server/main.go +++ b/cmd/dendrite-monolith-server/main.go @@ -17,6 +17,7 @@ package main import ( "flag" "net/http" + "time" "github.com/matrix-org/dendrite/appservice" "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. go func() { 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 go func() {