Browse Source

RootShell: hoist out synchronization

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
master
Jason A. Donenfeld 6 years ago
parent
commit
23c09eb655
1 changed files with 7 additions and 11 deletions
  1. +7
    -11
      app/src/main/java/com/wireguard/android/util/RootShell.java

+ 7
- 11
app/src/main/java/com/wireguard/android/util/RootShell.java View File

@@ -57,13 +57,11 @@ public class RootShell {
return false;
}

public boolean isRunning() {
public synchronized boolean isRunning() {
try {
// Throws an exception if the process hasn't finished yet.
synchronized (this) {
if (process != null)
process.exitValue();
}
if (process != null)
process.exitValue();
} catch (final IllegalThreadStateException ignored) {
// The existing process is still running.
return true;
@@ -149,12 +147,10 @@ public class RootShell {
}
}

public void stop() throws IOException {
synchronized (this) {
if (process != null) {
process.destroy();
process = null;
}
public synchronized void stop() throws IOException {
if (process != null) {
process.destroy();
process = null;
}
}



Loading…
Cancel
Save