Skip to content

Thread btrMgr_IncomingConnectionAuthentication to unblock device status callback#70

Draft
Copilot wants to merge 6 commits intodevelopfrom
copilot/run-btrmgr-incoming-connection-authentication
Draft

Thread btrMgr_IncomingConnectionAuthentication to unblock device status callback#70
Copilot wants to merge 6 commits intodevelopfrom
copilot/run-btrmgr-incoming-connection-authentication

Conversation

Copy link

Copilot AI commented Feb 19, 2026

btrMgr_IncomingConnectionAuthentication blocks for up to 20 seconds polling for UI response, preventing other device status events from being processed.

Changes

New async implementation:

  • btrMgr_IncomingConnectionAuthenticationAsync() - launches authentication in separate GThread
  • btrMgr_IncomingConnectionAuthenticationThread() - thread function containing authentication logic
  • BTRMGR_AuthenticationThreadData_t - structure to pass device status data to thread

Call site updates:
Updated 3 locations in btrMgr_DeviceStatusCb() to use async version:

  • AUTO_CONNECT_ENABLED path for HID gamepads
  • Disconnected state handling
  • Connecting state handling

Preserved synchronous function:
Original btrMgr_IncomingConnectionAuthentication() kept for startup/initialization where blocking is acceptable.

Example

Before:

// Blocks callback for 20 seconds
int auth = 0;
btrMgr_IncomingConnectionAuthentication(p_StatusCB, &auth);
if (!auth) break;

After:

// Returns immediately, authentication continues in thread
btrMgr_IncomingConnectionAuthenticationAsync(p_StatusCB);

Thread Safety

Accesses global variables (gEventRespReceived, gAcceptConnection, gListOfPairedDevices) without mutexes, maintaining existing thread safety characteristics. Comment added noting future hardening opportunity.

Deliverables

  • btrmgr_threading.patch - Git patch file
  • THREADING_NOTES.md - Technical documentation
  • IMPLEMENTATION_SUMMARY.md - Implementation details

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 5 commits February 19, 2026 13:00
- Add BTRMGR_AuthenticationThreadData_t structure to pass data to thread
- Add btrMgr_IncomingConnectionAuthenticationThread as thread function
- Add btrMgr_IncomingConnectionAuthenticationAsync to launch thread
- Update device status callback to use async version
- Keep original function for synchronous startup case

Co-authored-by: natrajmuthusamy <52849136+natrajmuthusamy@users.noreply.github.com>
Co-authored-by: natrajmuthusamy <52849136+natrajmuthusamy@users.noreply.github.com>
- Fix inconsistent indentation in thread function
- Add comments explaining thread safety considerations
- Add comment about g_thread_unref usage

Co-authored-by: natrajmuthusamy <52849136+natrajmuthusamy@users.noreply.github.com>
Co-authored-by: natrajmuthusamy <52849136+natrajmuthusamy@users.noreply.github.com>
Complete implementation of threaded authentication for incoming connections

Co-authored-by: natrajmuthusamy <52849136+natrajmuthusamy@users.noreply.github.com>
Copilot AI changed the title [WIP] Run btrMgr_IncomingConnectionAuthentication in a separate thread Thread btrMgr_IncomingConnectionAuthentication to unblock device status callback Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants