Skip to content

Fix race condition when closing redundant Bluetooth sockets

akwizgran requested to merge bluetooth-race into master

The Bluetooth invitation code has a race condition: if Alice and Bob connect to each other at roughly the same time, they each consider their outgoing socket to be redundant and close it, resulting in both sockets being closed. This can be triggered pretty reliably by using two phones of the same model and pressing 'Continue' at the same time on both phones.

When more than one invitation socket is opened, Alice should pick which one to use and Bob should use whichever one Alice picks, which Bob can detect by trying to read from both sockets.

Hopefully the Bluetooth invitation code will be retired when #117 (closed) is merged, but I'm putting this up for review in case we need to keep Bluetooth as a fallback method.

Merge request reports