From fb98b0c8e0e1b22f006493bd4311c2407cc438db Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 4 Oct 2013 11:22:03 -0400 Subject: updated nuget --- .../WebSocket/AlchemyServer.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs') 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(); + /// /// Releases unmanaged and - optionally - managed resources. /// /// true to release both managed and unmanaged resources; false to release only unmanaged resources. 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; } } } -- cgit v1.2.3