From ee4c80e4d1b17529212d766ccb44fe21b26bb728 Mon Sep 17 00:00:00 2001 From: Goffi Date: Sun, 3 May 2026 11:32:11 +0200 Subject: [PATCH] plugin XEP-0384: Fix reentrancy loop: When `prepare_for_profile` is called during connection init, an infinite loop could happen with 'get_session_manager` calling `prepare_for_profile`. A check is added to early exit if the profile is already being prepared, avoiding this issue. --- libervia/backend/plugins/plugin_xep_0384.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libervia/backend/plugins/plugin_xep_0384.py b/libervia/backend/plugins/plugin_xep_0384.py index 77839b1b..8d005c35 100644 --- a/libervia/backend/plugins/plugin_xep_0384.py +++ b/libervia/backend/plugins/plugin_xep_0384.py @@ -2702,6 +2702,13 @@ class OMEMO: @param items_event: The event. @param profile: The profile this event belongs to. """ + # Skip if session manager is already being built to prevent reentrancy loop + # (device list refresh during init triggers this handler again) + if profile in self.__session_manager_waiters: + log.debug( + f"Ignoring device list update for {profile} (session manager being built)" + ) + return sender = cast(jid.JID, items_event.sender) items = cast(List[domish.Element], items_event.items)