aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs')
-rw-r--r--MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs21
1 files changed, 14 insertions, 7 deletions
diff --git a/MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs b/MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs
index 56296ba84..14d468a8e 100644
--- a/MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs
+++ b/MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs
@@ -69,7 +69,7 @@ namespace MediaBrowser.Server.Implementations.WebSocket
_hasStarted = true;
}
- catch (SocketException ex)
+ catch (Exception ex)
{
_logger.ErrorException("The web socket server is unable to start on port {0} due to a Socket error. This can occasionally happen when the operating system takes longer than usual to release the IP bindings from the previous session. This can take up to five minutes. Please try waiting or rebooting the system.", ex, portNumber);
@@ -119,21 +119,28 @@ namespace MediaBrowser.Server.Implementations.WebSocket
GC.SuppressFinalize(this);
}
+ private readonly object _syncLock = new object();
+
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool dispose)
{
- if (WebSocketServer != null)
+ lock (_syncLock)
{
- if (_hasStarted)
+ if (WebSocketServer != null)
{
- WebSocketServer.Stop();
+ if (_hasStarted)
+ {
+ _logger.Debug("Stopping alchemy server");
+ WebSocketServer.Stop();
+ }
+
+ _logger.Debug("Disposing alchemy server");
+ WebSocketServer.Dispose();
+ WebSocketServer = null;
}
-
- WebSocketServer.Dispose();
- WebSocketServer = null;
}
}
}