aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server/SocketSharp/WebSocketSharpListener.cs
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2019-02-16 17:05:05 +0100
committerGitHub <noreply@github.com>2019-02-16 17:05:05 +0100
commit64a4f259a20408fe0a3c954d71d2b975d48c3d3e (patch)
treeb991ccbee7ac7a6250e4db60252557991724b3ad /Jellyfin.Server/SocketSharp/WebSocketSharpListener.cs
parent3a5bbcf2a879dc78eda969e3e91c02f79e60bf0e (diff)
parent25c2267a89af5c2e82774c638cdad0defcc894b5 (diff)
Merge branch 'master' into async
Diffstat (limited to 'Jellyfin.Server/SocketSharp/WebSocketSharpListener.cs')
-rw-r--r--Jellyfin.Server/SocketSharp/WebSocketSharpListener.cs44
1 files changed, 24 insertions, 20 deletions
diff --git a/Jellyfin.Server/SocketSharp/WebSocketSharpListener.cs b/Jellyfin.Server/SocketSharp/WebSocketSharpListener.cs
index 57f42845c..736f9feef 100644
--- a/Jellyfin.Server/SocketSharp/WebSocketSharpListener.cs
+++ b/Jellyfin.Server/SocketSharp/WebSocketSharpListener.cs
@@ -91,8 +91,11 @@ namespace Jellyfin.Server.SocketSharp
{
var url = request.Url.ToString();
- logger.LogInformation("{0} {1}. UserAgent: {2}",
- request.IsWebSocketRequest ? "WS" : "HTTP " + request.HttpMethod, url, request.UserAgent ?? string.Empty);
+ logger.LogInformation(
+ "{0} {1}. UserAgent: {2}",
+ request.IsWebSocketRequest ? "WS" : "HTTP " + request.HttpMethod,
+ url,
+ request.UserAgent ?? string.Empty);
}
private Task InitTask(HttpListenerContext context, CancellationToken cancellationToken)
@@ -200,7 +203,7 @@ namespace Jellyfin.Server.SocketSharp
}
catch (ObjectDisposedException)
{
- //TODO Investigate and properly fix.
+ // TODO: Investigate and properly fix.
}
catch (Exception ex)
{
@@ -222,38 +225,39 @@ namespace Jellyfin.Server.SocketSharp
public Task Stop()
{
_disposeCancellationTokenSource.Cancel();
-
- if (_listener != null)
- {
- _listener.Close();
- }
+ _listener?.Close();
return Task.CompletedTask;
}
+ /// <summary>
+ /// Releases the unmanaged resources and disposes of the managed resources used.
+ /// </summary>
public void Dispose()
{
Dispose(true);
+ GC.SuppressFinalize(this);
}
private bool _disposed;
- private readonly object _disposeLock = new object();
+
+ /// <summary>
+ /// Releases the unmanaged resources and disposes of the managed resources used.
+ /// </summary>
+ /// <param name="disposing">Whether or not the managed resources should be disposed</param>
protected virtual void Dispose(bool disposing)
{
- if (_disposed) return;
-
- lock (_disposeLock)
+ if (_disposed)
{
- if (_disposed) return;
-
- if (disposing)
- {
- Stop();
- }
+ return;
+ }
- //release unmanaged resources here...
- _disposed = true;
+ if (disposing)
+ {
+ Stop().GetAwaiter().GetResult();
}
+
+ _disposed = true;
}
}
}