From a0ad911688479e818452a8998d288e5a0f655ef6 Mon Sep 17 00:00:00 2001 From: strawberry Date: Sun, 31 Mar 2024 15:37:30 -0400 Subject: [PATCH] stop sending make_join requests after 50 failures this is a very generous number Signed-off-by: strawberry --- src/api/client_server/membership.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/api/client_server/membership.rs b/src/api/client_server/membership.rs index e6b1462a..a6eb043d 100644 --- a/src/api/client_server/membership.rs +++ b/src/api/client_server/membership.rs @@ -1169,6 +1169,7 @@ async fn make_join_request( if let Err(ref e) = make_join_response { trace!("make_join ErrorKind string: {:?}", e.error_code().to_string()); + // converting to a string is necessary (i think) because ruma is forcing us to // fill in the struct for M_INCOMPATIBLE_ROOM_VERSION if e.error_code() @@ -1190,6 +1191,15 @@ async fn make_join_request( Err(Error::BadServerResponse("Room version is not supported by Conduwuit")); return make_join_response_and_server; } + + if make_join_counter > 50 { + warn!( + "50 servers failed to provide valid make_join response, assuming no server can assist in joining." + ); + make_join_response_and_server = + Err(Error::BadServerResponse("No server available to assist in joining.")); + return make_join_response_and_server; + } } make_join_response_and_server = make_join_response.map(|r| (r, remote_server.clone()));