diff options
| author | Joshua Boniface <joshua@boniface.me> | 2022-07-24 12:35:46 -0400 |
|---|---|---|
| committer | Joshua Boniface <joshua@boniface.me> | 2022-07-24 12:35:46 -0400 |
| commit | 410871e14882fe8622c4d992658eb30f0c850a3e (patch) | |
| tree | cf1d19275a3e56ea1863eea796488ba760b9ccbd /Emby.Server.Implementations/Session/WebSocketController.cs | |
| parent | 8ccd9d8dfab5fa766467500beddd8041ebcdfb5c (diff) | |
Backport pull request #7732 from jellyfin/release-10.8.z
Fix to make web sockets close gracefully on server shutdown
Authored-by: luke brown <luke92brown@gmail.com>
Merged-by: Cody Robibero <cody@robibe.ro>
Original-merge: ee22feb89a34632a4cc3a350733dd57c6be863ec
Diffstat (limited to 'Emby.Server.Implementations/Session/WebSocketController.cs')
| -rw-r--r-- | Emby.Server.Implementations/Session/WebSocketController.cs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Emby.Server.Implementations/Session/WebSocketController.cs b/Emby.Server.Implementations/Session/WebSocketController.cs index d21b6a929..1f3248f07 100644 --- a/Emby.Server.Implementations/Session/WebSocketController.cs +++ b/Emby.Server.Implementations/Session/WebSocketController.cs @@ -14,7 +14,7 @@ using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Session { - public sealed class WebSocketController : ISessionController, IDisposable + public sealed class WebSocketController : ISessionController, IAsyncDisposable, IDisposable { private readonly ILogger<WebSocketController> _logger; private readonly ISessionManager _sessionManager; @@ -99,6 +99,23 @@ namespace Emby.Server.Implementations.Session foreach (var socket in _sockets) { socket.Closed -= OnConnectionClosed; + socket.Dispose(); + } + + _disposed = true; + } + + public async ValueTask DisposeAsync() + { + if (_disposed) + { + return; + } + + foreach (var socket in _sockets) + { + socket.Closed -= OnConnectionClosed; + await socket.DisposeAsync().ConfigureAwait(false); } _disposed = true; |
