Browse Source

Fix logic to match comment

mirokuratczyk 3 years ago
parent
commit
d8296e8a3c
1 changed files with 2 additions and 4 deletions
  1. 2 4
      MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.m

+ 2 - 4
MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.m

@@ -1514,12 +1514,10 @@ typedef NS_ERROR_ENUM(PsiphonTunnelErrorDomain, PsiphonTunnelErrorCode) {
 
 
     previousNetworkStatus = atomic_exchange(&self->currentNetworkStatus, networkStatus);
     previousNetworkStatus = atomic_exchange(&self->currentNetworkStatus, networkStatus);
 
 
-    // Restart if the state has changed, unless the previous state was
+    // Restart if the network status or interface has changed, unless the previous status was
     // NetworkReachabilityNotReachable, because the tunnel should be waiting for connectivity in
     // NetworkReachabilityNotReachable, because the tunnel should be waiting for connectivity in
     // that case.
     // that case.
-    BOOL restartDueToNetworkStatusChange = networkStatus != previousNetworkStatus && previousNetworkStatus != NetworkReachabilityNotReachable;
-
-    if (restartDueToNetworkStatusChange || interfaceChanged) {
+    if ((networkStatus != previousNetworkStatus || interfaceChanged) && previousNetworkStatus != NetworkReachabilityNotReachable) {
         GoPsiReconnectTunnel();
         GoPsiReconnectTunnel();
     }
     }
 }
 }