Преглед на файлове

Callstack logging when closing GetFile stream

Source commit: f43d5b6f370c3a8e1e34359fd5c99c2ce15b34d5
Martin Prikryl преди 4 години
родител
ревизия
74c2283b66
променени са 1 файла, в които са добавени 25 реда и са изтрити 19 реда
  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();
+                        }
                     }
                 }