connector/chatsync: fix XChat chat info sync self-deadlock in portal event handler#107
Open
Fizzadar wants to merge 1 commit into
Open
connector/chatsync: fix XChat chat info sync self-deadlock in portal event handler#107Fizzadar wants to merge 1 commit into
Fizzadar wants to merge 1 commit into
Conversation
…tal event handler With a synchronous portal event queue (PortalEventBuffer=0), queueing a ChatInfoChange for the same portal from inside its own event handler (via RefreshConversationKeys during message conversion) deadlocks on portal.eventsLock. Apply the chat info update directly in that case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With a synchronous portal event queue (
PortalEventBuffer = 0, as set by the Beeper client SDK),syncXChatChannelcan be reached from inside a portal's own event handler (message conversion →RefreshConversationKeys→HandleConversationDataRefresh). Queueing aChatInfoChangefor the same portal from there blocks forever onportal.eventsLock, which the handler's own dispatcher holds.Bridge.Startthen never returns, hanging bridge stop/start and leaving client sends stuck.Fix
When
bridgev2.GetRemoteEventFromContext(ctx)shows we are already inside this portal's event handler, apply the chat info viaportal.UpdateInfodirectly (same as bridgev2'shandleRemoteChatResync) instead of re-entering the event queue.Linear: https://linear.app/beeper/issue/BIOS-35204/sanakh-ios-room-send-queue-waited-on-sdk-restart-leaving-whatsapp