Add SystemShuttingDown ErrorCode handling in core ExitCallback

Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
Loren Eteval
2023-09-03 15:12:29 +08:00
parent 6272c8ba59
commit 58f24ef640
2 changed files with 15 additions and 3 deletions
+10 -2
View File
@@ -97,6 +97,10 @@ class ConnectAction(Action):
assert self.coreRunning
assert self.coreName == XrayCore.name()
if exitcode == XrayCore.ExitCode.SystemShuttingDown:
# System shutting down. Do nothing
return
if exitcode == XrayCore.ExitCode.ConfigurationError:
if not self.isConnecting():
# Protect connecting action. Mandatory
@@ -142,6 +146,10 @@ class ConnectAction(Action):
assert self.coreRunning
assert self.coreName == Hysteria.name()
if exitcode == Hysteria.ExitCode.SystemShuttingDown:
# System shutting down. Do nothing
return
if exitcode == Hysteria.ExitCode.ConfigurationError:
if not self.isConnecting():
# Protect connecting action. Mandatory
@@ -182,6 +190,8 @@ class ConnectAction(Action):
)
def stopCore(self):
self.TorRelay.stop()
self.XrayCore.registerExitCallback(None)
self.Hysteria.registerExitCallback(None)
@@ -189,8 +199,6 @@ class ConnectAction(Action):
self.XrayCore.stop()
self.Hysteria.stop()
self.TorRelay.stop()
self.coreRunning = False
def showConnectingProgressBar(self):
+5 -1
View File
@@ -1,4 +1,4 @@
from Furious.Utility.Constants import PLATFORM, ROOT_DIR, DATA_DIR
from Furious.Utility.Constants import PLATFORM
from Furious.Utility.Utility import getAbsolutePath
from PySide6 import QtCore
@@ -96,6 +96,8 @@ class XrayCore(Core):
ConfigurationError = 23
# Windows: 4294967295. Darwin, Linux: 255 (-1)
ServerStartFailure = 4294967295 if PLATFORM == 'Windows' else 255
# Windows shutting down
SystemShuttingDown = 0x40010004
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -137,6 +139,8 @@ class Hysteria(Core):
class ExitCode:
ConfigurationError = 23
RemoteNetworkError = 3
# Windows shutting down
SystemShuttingDown = 0x40010004
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)