Run btrMgr_IncomingConnectionAuthentication on separate thread in DeviceStatusCb#74
Draft
Run btrMgr_IncomingConnectionAuthentication on separate thread in DeviceStatusCb#74
Conversation
…viceStatusCb Co-authored-by: natrajmuthusamy <52849136+natrajmuthusamy@users.noreply.github.com>
… thread safety Co-authored-by: natrajmuthusamy <52849136+natrajmuthusamy@users.noreply.github.com>
Co-authored-by: natrajmuthusamy <52849136+natrajmuthusamy@users.noreply.github.com>
…cation complete Co-authored-by: natrajmuthusamy <52849136+natrajmuthusamy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Investigate running btrMgr_IncomingConnectionAuthentication on a separate thread
Run btrMgr_IncomingConnectionAuthentication on separate thread in DeviceStatusCb
Feb 20, 2026
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.
btrMgr_IncomingConnectionAuthenticationblocks the BTRCore callback thread for up to 20 seconds polling for UI response, preventing other Bluetooth device events from being processed during authentication.Changes
Threading infrastructure:
stBTRMgrAuthThreadData: Holds device status and snapshotted global handlesbtrMgr_IncomingConnectionAuthenticationThread: Thread entry point that runs authentication and handles result (disconnect on failure, post device found event on success)btrMgr_SpawnAuthenticationThread: Helper function encapsulating thread spawn logicModified call sites (4):
BTRMGR_ConnectGamepads_StartUp- startup reconnectionbtrMgr_DeviceStatusCb- AUTO_CONNECT_ENABLED, disconnected state, connecting statePattern:
Thread Safety
Accesses same globals as original synchronous implementation (ghBTRCoreHdl, ghBTRMgrDevHdlLastDisconnected, gfpcBBTRMgrEventOut). Global handles are snapshotted at thread creation to minimize TOCTOU issues. No new race conditions introduced.
Uses GLib threading (g_thread_new/g_thread_unref) and memory allocation (g_malloc/g_free) consistent with existing patterns in codebase.
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.