From 7197e46b53f65956d07332131461d7b76a9227a1 Mon Sep 17 00:00:00 2001 From: HYec Date: Sat, 6 Jan 2018 22:06:15 +0800 Subject: [PATCH] Close sockets before stop plugins --- shadowsocks-csharp/Controller/ShadowsocksController.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/shadowsocks-csharp/Controller/ShadowsocksController.cs b/shadowsocks-csharp/Controller/ShadowsocksController.cs index 8f2fd018..60fc6e36 100644 --- a/shadowsocks-csharp/Controller/ShadowsocksController.cs +++ b/shadowsocks-csharp/Controller/ShadowsocksController.cs @@ -490,8 +490,6 @@ namespace Shadowsocks.Controller protected void Reload() { - StopPlugins(); - Encryption.RNG.Reload(); // some logic in configuration updated the config when saving, we need to read it again _config = Configuration.Load(); @@ -521,6 +519,10 @@ namespace Shadowsocks.Controller { _listener.Stop(); } + + // + StopPlugins(); + // don't put PrivoxyRunner.Start() before pacServer.Stop() // or bind will fail when switching bind address from 0.0.0.0 to 127.0.0.1 // though UseShellExecute is set to true now @@ -554,7 +556,8 @@ namespace Shadowsocks.Controller if (e is SocketException) { SocketException se = (SocketException)e; - if (se.SocketErrorCode == SocketError.AccessDenied) + if (se.SocketErrorCode == SocketError.AccessDenied || + se.SocketErrorCode == SocketError.AddressAlreadyInUse) { e = new Exception(I18N.GetString("Port already in use"), e); }