Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
MainModule FileName only exists in Win32.
  • Loading branch information
2dust committed Nov 3, 2024
1 parent bb661d4 commit 4f05b93
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 28 deletions.
10 changes: 5 additions & 5 deletions v2rayN/AmazTool/UpgradeApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public static void Upgrade(string fileName)
Console.WriteLine("Try to end the process(尝试结束进程).");
try
{
var path = GetPath(V2rayN);
Console.WriteLine(path);
var existing = Process.GetProcessesByName(V2rayN);
var pp = existing.FirstOrDefault(p => p.MainModule?.FileName != null && p.MainModule?.FileName.Contains(path) == true);
pp?.Kill();
pp?.WaitForExit(1000);
foreach (var pp in existing)
{
pp?.Kill();
pp?.WaitForExit(1000);
}
}
catch (Exception ex)
{
Expand Down
22 changes: 0 additions & 22 deletions v2rayN/ServiceLib/Handler/CoreHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,40 +108,18 @@ public async Task CoreStop()
{
try
{
bool hasProc = false;
if (_process != null)
{
await KillProcess(_process);
_process.Dispose();
_process = null;
hasProc = true;
}

if (_processPre != null)
{
await KillProcess(_processPre);
_processPre.Dispose();
_processPre = null;
hasProc = true;
}

if (!hasProc)
{
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo();
foreach (var it in coreInfo)
{
if (it.CoreType == ECoreType.v2rayN)
{
continue;
}
foreach (var name in it.CoreExes)
{
var path = Utils.GetBinPath(Utils.GetExeName(name), it.CoreType.ToString());
var existing = Process.GetProcessesByName(name);
var pp = existing.FirstOrDefault(p => p.MainModule?.FileName != null && p.MainModule?.FileName.Contains(path) == true);
await KillProcess(pp);
}
}
}
}
catch (Exception ex)
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public async Task MyAppExitAsync(bool blWindowsShutDown)
await ProfileExHandler.Instance.SaveTo();
await StatisticsHandler.Instance.SaveTo();
StatisticsHandler.Instance.Close();
CoreHandler.Instance.CoreStop();
await CoreHandler.Instance.CoreStop();

Logging.SaveLog("MyAppExit End");
}
Expand Down

0 comments on commit 4f05b93

Please sign in to comment.