Skip to content

Hold a wake lock while Tor is connected to the internet

akwizgran requested to merge 314-tor-sleep into master

This is a partial fix for #314 (closed). As noted on that ticket, if a Tor connection is lost for any reason other than the device sleeping, the plugin won't try to replace the lost connection. I'm leaving the ticket open until that more general issue is solved.

The Tor plugin uses several variables to keep track of its connectivity status. This patch refactors those variables into an inner class to improve readability and ensure they're accessed atomically. However, it's still possible for the plugin's state to become inconsistent with the state of the Tor process. For example, calls to updateConnectionStatus() may run concurrently on the IO executor, so their calls to enableNetwork() may be interleaved. As usual, locking would solve this problem but create the potential for deadlock, so I won't try to solve it in this patch.

Merge request reports