summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2022-06-26 19:33:20 +0200
committercyBerta <cyberta@riseup.net>2022-07-19 00:03:57 +0200
commitfece9e3133a39b885d014cabf62cd905b6667348 (patch)
treefb5967815f43b80cb06f2d09bae94759fd425ac0 /app/src
parentbfa89faf60d1c88250745f617ff38b13e2a7e34d (diff)
handle multi-threaded access to obfsvpn client state flags correctly
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/pluggableTransports/ObfsVpnClient.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/ObfsVpnClient.java b/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/ObfsVpnClient.java
index 632dc878..635f795d 100644
--- a/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/ObfsVpnClient.java
+++ b/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/ObfsVpnClient.java
@@ -4,6 +4,7 @@ import android.util.Log;
import java.util.Observable;
import java.util.Observer;
+import java.util.concurrent.atomic.AtomicBoolean;
import client.Client_;
import de.blinkt.openvpn.core.ConnectionStatus;
@@ -15,9 +16,9 @@ public class ObfsVpnClient implements Observer {
public static final String SOCKS_IP = "127.0.0.1";
private static final String TAG = ObfsVpnClient.class.getSimpleName();
- private boolean noNetwork;
+ private volatile boolean noNetwork;
// TODO: implement error signaling go->java
- private boolean isErrorHandling;
+ private AtomicBoolean isErrorHandling = new AtomicBoolean(false);
private final client.Client_ obfsVpnClient;
private final Object LOCK = new Object();
@@ -34,6 +35,9 @@ public class ObfsVpnClient implements Observer {
obfsVpnClient.start();
} catch (Exception e) {
e.printStackTrace();
+ if (noNetwork) {
+ isErrorHandling.set(true);
+ }
}
}).start();
@@ -56,6 +60,7 @@ public class ObfsVpnClient implements Observer {
e.printStackTrace();
VpnStatus.logError("[obfsvpn] " + e.getLocalizedMessage());
}
+ isErrorHandling.set(false);
Log.d(TAG, "stopping obfsVpnClient releasing LOCK ...");
}
}
@@ -73,8 +78,7 @@ public class ObfsVpnClient implements Observer {
noNetwork = true;
} else {
noNetwork = false;
- if (isErrorHandling) {
- isErrorHandling = false;
+ if (isErrorHandling.getAndSet(false)) {
stop();
start();
}