diff --git a/src/realm/sync/client.cpp b/src/realm/sync/client.cpp index 214a938969..5a1d130727 100644 --- a/src/realm/sync/client.cpp +++ b/src/realm/sync/client.cpp @@ -827,15 +827,7 @@ bool SessionImpl::process_flx_bootstrap_message(const DownloadMessage& message) return true; } - try { - process_pending_flx_bootstrap(); // throws - } - catch (const IntegrationException& e) { - on_integration_failure(e); - } - catch (...) { - on_integration_failure(IntegrationException(exception_to_status())); - } + try_process_pending_flx_bootstrap(); return true; } @@ -847,6 +839,10 @@ void SessionImpl::process_pending_flx_bootstrap() if (!m_is_flx_sync_session || m_state != State::Active) { return; } + // Ignore the call if the client detects an error. + if (m_client_error) { + return; + } auto bootstrap_store = m_wrapper.get_flx_pending_bootstrap_store(); if (!bootstrap_store->has_pending()) { return; @@ -917,6 +913,19 @@ void SessionImpl::process_pending_flx_bootstrap() REALM_ASSERT_EX(action == SyncClientHookAction::NoAction || action == SyncClientHookAction::EarlyReturn, action); } +void SessionImpl::try_process_pending_flx_bootstrap() +{ + try { + process_pending_flx_bootstrap(); // throws + } + catch (const IntegrationException& error) { + on_integration_failure(error); + } + catch (...) { + on_integration_failure(IntegrationException(exception_to_status())); + } +} + void SessionImpl::on_flx_sync_error(int64_t version, std::string_view err_msg) { // Ignore the call if the session is not active diff --git a/src/realm/sync/noinst/client_impl_base.cpp b/src/realm/sync/noinst/client_impl_base.cpp index 96bbc2456d..6f327e2e5c 100644 --- a/src/realm/sync/noinst/client_impl_base.cpp +++ b/src/realm/sync/noinst/client_impl_base.cpp @@ -1513,15 +1513,7 @@ void Session::cancel_resumption_delay() if (unbind_process_complete()) initiate_rebind(); // Throws - try { - process_pending_flx_bootstrap(); // throws - } - catch (const IntegrationException& error) { - on_integration_failure(error); - } - catch (...) { - on_integration_failure(IntegrationException(exception_to_status())); - } + try_process_pending_flx_bootstrap(); m_conn.one_more_active_unsuspended_session(); // Throws if (m_try_again_activation_timer) { @@ -1709,6 +1701,8 @@ void Session::activate() REALM_ASSERT(!m_suspended); m_conn.one_more_active_unsuspended_session(); // Throws + try_process_pending_flx_bootstrap(); + // Checks if there is a pending client reset handle_pending_client_reset_acknowledgement(); } diff --git a/src/realm/sync/noinst/client_impl_base.hpp b/src/realm/sync/noinst/client_impl_base.hpp index 3b4b20ed7a..37daa16aa5 100644 --- a/src/realm/sync/noinst/client_impl_base.hpp +++ b/src/realm/sync/noinst/client_impl_base.hpp @@ -932,6 +932,7 @@ class ClientImpl::Session { // Processes any pending FLX bootstraps, if one exists. Otherwise this is a noop. void process_pending_flx_bootstrap(); + void try_process_pending_flx_bootstrap(); bool client_reset_if_needed(); void handle_pending_client_reset_acknowledgement(); @@ -941,7 +942,6 @@ class ClientImpl::Session { void begin_resumption_delay(const ProtocolErrorInfo& error_info); void clear_resumption_delay_state(); -private: Connection& m_conn; const session_ident_type m_ident; @@ -1398,15 +1398,7 @@ inline void ClientImpl::Session::connection_established(bool fast_reconnect) // the bind messsage call_debug_hook(SyncClientHookEvent::SessionConnected); - try { - process_pending_flx_bootstrap(); // throws - } - catch (const IntegrationException& error) { - on_integration_failure(error); - } - catch (...) { - on_integration_failure(IntegrationException(exception_to_status())); - } + try_process_pending_flx_bootstrap(); if (!m_suspended) { // Ready to send BIND message