Explorar o código

Callstack logging when closing GetFile stream

(cherry picked from commit 74c2283b66feb1630a219066071f316a39c51a9f)

Source commit: bd03c9c9d2a91e995739b13b72c8eccbac8608d5
Martin Prikryl %!s(int64=4) %!d(string=hai) anos
pai
achega
78bfa97c21
Modificáronse 1 ficheiros con 25 adicións e 19 borrados
  1. 25 19
      dotnet/Session.cs

+ 25 - 19
dotnet/Session.cs

@@ -1047,38 +1047,44 @@ namespace WinSCP
 
                 void onGetEnd()
                 {
-                    try
-                    {
-                        // This can throw
-                        progressHandler?.Dispose();
-                    }
-                    finally
+                    using (Logger.CreateCallstack())
                     {
                         try
                         {
-                            groupReader?.Dispose();
+                            // This can throw
+                            progressHandler?.Dispose();
                         }
                         finally
                         {
-                            _process.StdOut = null;
-                            // Only after disposing the group reader, so when called from onGetEndWithExit, the Check() has all failures.
-                            operationResultGuard?.Dispose();
+                            try
+                            {
+                                groupReader?.Dispose();
+                            }
+                            finally
+                            {
+                                _process.StdOut = null;
+                                // Only after disposing the group reader, so when called from onGetEndWithExit, the Check() has all failures.
+                                operationResultGuard?.Dispose();
+                            }
                         }
                     }
                 }
 
                 void onGetEndWithExit()
                 {
-                    Logger.WriteLine("Closing download stream");
-                    try
+                    using (Logger.CreateCallstack())
                     {
-                        onGetEnd();
-                    }
-                    finally
-                    {
-                        Logger.Lock.Exit();
-                        Logger.WriteLine("Closed download stream");
-                        result.Check();
+                        Logger.WriteLine("Closing download stream");
+                        try
+                        {
+                            onGetEnd();
+                        }
+                        finally
+                        {
+                            Logger.Lock.Exit();
+                            Logger.WriteLine("Closed download stream");
+                            result.Check();
+                        }
                     }
                 }