From 9ced043be0c9af60a353413a2ca4ac6bae8bf662 Mon Sep 17 00:00:00 2001 From: Mykola Baibuz Date: Wed, 25 Dec 2024 22:10:55 +0200 Subject: [PATCH] Improve XRay protocol process close --- client/protocols/xrayprotocol.cpp | 13 +++++-------- ipc/ipctun2socksprocess.cpp | 13 +++++++------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/client/protocols/xrayprotocol.cpp b/client/protocols/xrayprotocol.cpp index 2dfbcc21a..9b77b3c0b 100755 --- a/client/protocols/xrayprotocol.cpp +++ b/client/protocols/xrayprotocol.cpp @@ -68,13 +68,10 @@ ErrorCode XrayProtocol::start() connect(&m_xrayProcess, QOverload::of(&QProcess::finished), this, [this](int exitCode, QProcess::ExitStatus exitStatus) { qDebug().noquote() << "XrayProtocol finished, exitCode, exitStatus" << exitCode << exitStatus; setConnectionState(Vpn::ConnectionState::Disconnected); - if (exitStatus != QProcess::NormalExit) { - emit protocolError(amnezia::ErrorCode::XrayExecutableCrashed); - stop(); - } - if (exitCode != 0) { - emit protocolError(amnezia::ErrorCode::InternalError); - stop(); + if ((exitStatus != QProcess::NormalExit) || (exitCode != 0)){ + if (exitCode != 62097 ){ + stop(); + } } }); @@ -177,7 +174,7 @@ void XrayProtocol::stop() IpcClient::Interface()->StartRoutingIpv6(); #endif qDebug() << "XrayProtocol::stop()"; - m_xrayProcess.terminate(); + m_xrayProcess.kill(); if (m_t2sProcess) { m_t2sProcess->stop(); } diff --git a/ipc/ipctun2socksprocess.cpp b/ipc/ipctun2socksprocess.cpp index ffcb1bcd0..3fa84ced5 100644 --- a/ipc/ipctun2socksprocess.cpp +++ b/ipc/ipctun2socksprocess.cpp @@ -54,12 +54,12 @@ void IpcProcessTun2Socks::start() connect(m_t2sProcess.data(), QOverload::of(&QProcess::finished), this, [this](int exitCode, QProcess::ExitStatus exitStatus) { qDebug().noquote() << "tun2socks finished, exitCode, exiStatus" << exitCode << exitStatus; emit setConnectionState(Vpn::ConnectionState::Disconnected); - if (exitStatus != QProcess::NormalExit){ - stop(); - } - if (exitCode !=0 ){ - stop(); + if ((exitStatus != QProcess::NormalExit) || (exitCode != 0)){ + if (exitCode != 62097 ){ + stop(); + } } + }); m_t2sProcess->start(); @@ -69,6 +69,7 @@ void IpcProcessTun2Socks::start() void IpcProcessTun2Socks::stop() { qDebug() << "IpcProcessTun2Socks::stop()"; - m_t2sProcess->close(); + m_t2sProcess->kill(); + m_t2sProcess->waitForFinished(3000); } #endif