Просмотр исходного кода

Reduce network change reconnect overhead (experimental)

- Keep existing Controller instead of restarting

- Eliminates: memory allocations; reopening of notice
  files; start up notices; embedded server list
  import
Rod Hynes 8 лет назад
Родитель
Сommit
641d5acf06

+ 1 - 1
MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.m

@@ -1147,7 +1147,7 @@
     // Restart if the state has changed, unless the previous state was NotReachable, because
     // the tunnel should be waiting for connectivity in that case.
     if (networkStatus != previousNetworkStatus && previousNetworkStatus != NotReachable) {
-        [self start];
+        GoPsiReconnectTunnel();
     }
 }
 

+ 11 - 0
MobileLibrary/psi/psi.go

@@ -149,6 +149,17 @@ func Stop() {
 	}
 }
 
+func ReconnectTunnel() {
+
+	controllerMutex.Lock()
+	defer controllerMutex.Unlock()
+
+	if controller != nil {
+		// TODO: ensure TerminateNextActiveTunnel is safe for use (see godoc)
+		controller.TerminateNextActiveTunnel()
+	}
+}
+
 // SetClientVerificationPayload is a passthrough to
 // Controller.SetClientVerificationPayloadForActiveTunnels.
 // Note: should only be called after Start() and before Stop(); otherwise,