ソースを参照

move the Dispose logic into DisposeAsyncCore

Luke Brown 3 年 前
コミット
0f7ba42987
1 ファイル変更26 行追加1 行削除
  1. 26 1
      Emby.Server.Implementations/ApplicationHost.cs

+ 26 - 1
Emby.Server.Implementations/ApplicationHost.cs

@@ -1234,7 +1234,7 @@ namespace Emby.Server.Implementations
         public async ValueTask DisposeAsync()
         {
             await DisposeAsyncCore().ConfigureAwait(false);
-            Dispose(true);
+            Dispose(false);
             GC.SuppressFinalize(this);
         }
 
@@ -1244,6 +1244,31 @@ namespace Emby.Server.Implementations
         /// <returns>A ValueTask.</returns>
         protected virtual async ValueTask DisposeAsyncCore()
         {
+            var type = GetType();
+
+            Logger.LogInformation("Disposing {Type}", type.Name);
+
+            foreach (var (part, _) in _disposableParts)
+            {
+                var partType = part.GetType();
+                if (partType == type)
+                {
+                    continue;
+                }
+
+                Logger.LogInformation("Disposing {Type}", partType.Name);
+
+                try
+                {
+                    part.Dispose();
+                }
+                catch (Exception ex)
+                {
+                    Logger.LogError(ex, "Error disposing {Type}", partType.Name);
+                }
+            }
+
+            // used for closing websockets
             foreach (var session in _sessionManager.Sessions)
             {
                 await session.DisposeAsync().ConfigureAwait(false);