Browse Source

tiny refactor

pull/478/head
Gang Zhuo 8 years ago
parent
commit
b3ce1c698a
1 changed files with 20 additions and 23 deletions
  1. +20
    -23
      shadowsocks-csharp/Controller/Service/PolipoRunner.cs

+ 20
- 23
shadowsocks-csharp/Controller/Service/PolipoRunner.cs View File

@@ -47,20 +47,7 @@ namespace Shadowsocks.Controller
Process[] existingPolipo = Process.GetProcessesByName("ss_privoxy");
foreach (Process p in existingPolipo)
{
try
{
p.CloseMainWindow();
p.WaitForExit(100);
if (!p.HasExited)
{
p.Kill();
p.WaitForExit();
}
}
catch (Exception e)
{
Logging.LogUsefulException(e);
}
KillProcess(p);
}
string polipoConfig = Resources.privoxy_conf;
_runningPort = this.GetFreePort();
@@ -86,20 +73,30 @@ namespace Shadowsocks.Controller
{
if (_process != null)
{
try
{
_process.Kill();
_process.WaitForExit();
}
catch (Exception e)
{
Logging.LogUsefulException(e);
}
KillProcess(_process);
_process = null;
}
RefreshTrayArea();
}
private static void KillProcess(Process p)
{
try
{
p.CloseMainWindow();
p.WaitForExit(100);
if (!p.HasExited)
{
p.Kill();
p.WaitForExit();
}
}
catch (Exception e)
{
Logging.LogUsefulException(e);
}
}
private int GetFreePort()
{
int defaultPort = 8123;


Loading…
Cancel
Save