android: run DNS/route diagnostics on their own executor
They can block for 10-30 s on a degraded network and delayed any profile load (connect, retry, profile switch) queued behind them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1b4fdc83d8
commit
7abac87140
1 file changed
+8
-3
+8
-3
@@ -157,6 +157,10 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
private VpnProfileDataSource mDataSource;
|
private VpnProfileDataSource mDataSource;
|
||||||
/* profile lookups are SQLite queries and must not run on the main thread */
|
/* profile lookups are SQLite queries and must not run on the main thread */
|
||||||
private final ExecutorService mProfileExecutor = Executors.newSingleThreadExecutor();
|
private final ExecutorService mProfileExecutor = Executors.newSingleThreadExecutor();
|
||||||
|
/* DNS/route diagnostics and private DNS lookups can block for many seconds
|
||||||
|
* on a bad network: keep them off the profile executor, or a connect
|
||||||
|
* queued behind them is delayed by that much */
|
||||||
|
private final ExecutorService mDiagExecutor = Executors.newSingleThreadExecutor();
|
||||||
private Thread mConnectionHandler;
|
private Thread mConnectionHandler;
|
||||||
/* read by the ConnectivityThread (UnderlyingNetworkTracker) too */
|
/* read by the ConnectivityThread (UnderlyingNetworkTracker) too */
|
||||||
private volatile VpnProfile mCurrentProfile;
|
private volatile VpnProfile mCurrentProfile;
|
||||||
@@ -454,6 +458,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
unbindService(mServiceConnection);
|
unbindService(mServiceConnection);
|
||||||
mBound = false;
|
mBound = false;
|
||||||
}
|
}
|
||||||
|
mDiagExecutor.shutdownNow();
|
||||||
/* queued profile loads must not run against the closed database */
|
/* queued profile loads must not run against the closed database */
|
||||||
mProfileExecutor.shutdownNow();
|
mProfileExecutor.shutdownNow();
|
||||||
try
|
try
|
||||||
@@ -975,7 +980,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
scheduleRouteDiagnostics();
|
scheduleRouteDiagnostics();
|
||||||
/* feed the userspace router for this connection (also picks
|
/* feed the userspace router for this connection (also picks
|
||||||
* up private DNS changes since the last push) */
|
* up private DNS changes since the last push) */
|
||||||
mProfileExecutor.execute(() -> {
|
mDiagExecutor.execute(() -> {
|
||||||
getPrivateDnsServers();
|
getPrivateDnsServers();
|
||||||
pushUserspaceRoutingData(this);
|
pushUserspaceRoutingData(this);
|
||||||
});
|
});
|
||||||
@@ -1017,7 +1022,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mProfileExecutor.execute(() -> {
|
mDiagExecutor.execute(() -> {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logDnsDiagnostics();
|
logDnsDiagnostics();
|
||||||
@@ -1267,7 +1272,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mProfileExecutor.execute(() -> {
|
mDiagExecutor.execute(() -> {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logRouteDiagnostics();
|
logRouteDiagnostics();
|
||||||
|
|||||||
Reference in new issue
Block a user