diff options
author | Tobias Brunner <tobias@strongswan.org> | 2012-08-09 16:03:14 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2012-08-13 11:22:20 +0200 |
commit | a7c8b166a1401532ebdbfd9c2e6111feb1740f74 (patch) | |
tree | d121410166f6e9720669b3f1e17751bb7a6ccb27 | |
parent | 496e096e7ba420fc1c7feba43157691fdf030c85 (diff) | |
download | strongswan-a7c8b166a1401532ebdbfd9c2e6111feb1740f74.tar.bz2 strongswan-a7c8b166a1401532ebdbfd9c2e6111feb1740f74.tar.xz |
Only call disconnect() from CharonVpnService if we are not already disconnecting
-rw-r--r-- | src/frontends/android/src/org/strongswan/android/logic/CharonVpnService.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/frontends/android/src/org/strongswan/android/logic/CharonVpnService.java b/src/frontends/android/src/org/strongswan/android/logic/CharonVpnService.java index 2938075a6..069f0007d 100644 --- a/src/frontends/android/src/org/strongswan/android/logic/CharonVpnService.java +++ b/src/frontends/android/src/org/strongswan/android/logic/CharonVpnService.java @@ -53,6 +53,7 @@ public class CharonVpnService extends VpnService implements Runnable private VpnProfile mNextProfile; private volatile boolean mProfileUpdated; private volatile boolean mTerminate; + private volatile boolean mIsDisconnecting; private VpnStateService mService; private final Object mServiceLock = new Object(); private final ServiceConnection mServiceConnection = new ServiceConnection() { @@ -200,6 +201,7 @@ public class CharonVpnService extends VpnService implements Runnable setProfile(mCurrentProfile); setError(ErrorState.NO_ERROR); setState(State.CONNECTING); + mIsDisconnecting = false; BuilderAdapter builder = new BuilderAdapter(mCurrentProfile.getName()); initializeCharon(builder); @@ -230,6 +232,7 @@ public class CharonVpnService extends VpnService implements Runnable if (mCurrentProfile != null) { setState(State.DISCONNECTING); + mIsDisconnecting = true; deinitializeCharon(); Log.i(TAG, "charon stopped"); mCurrentProfile = null; @@ -301,7 +304,10 @@ public class CharonVpnService extends VpnService implements Runnable if (mService != null) { mService.setError(error); - mService.disconnect(); + if (!mIsDisconnecting) + { + mService.disconnect(); + } } } } @@ -319,9 +325,9 @@ public class CharonVpnService extends VpnService implements Runnable case STATE_CHILD_SA_DOWN: synchronized (mServiceLock) { - /* since this state is also reached when the SA is closed remotely, - * we call disconnect() to make sure charon is properly deinitialized */ - if (mService != null) + /* if we are not actively disconnecting we assume the remote terminated + * the connection and call disconnect() to deinitialize charon properly */ + if (mService != null && !mIsDisconnecting) { mService.disconnect(); } |