diff --git a/src/Umbraco.Core/Diagnostics/MiniDump.cs b/src/Umbraco.Core/Diagnostics/MiniDump.cs index da5a729148..25f6e530e1 100644 --- a/src/Umbraco.Core/Diagnostics/MiniDump.cs +++ b/src/Umbraco.Core/Diagnostics/MiniDump.cs @@ -79,26 +79,28 @@ namespace Umbraco.Cms.Core.Diagnostics private static bool Write(IMarchal marchal, SafeHandle fileHandle, Option options, bool withException = false) { - var currentProcess = Process.GetCurrentProcess(); - var currentProcessHandle = currentProcess.Handle; - var currentProcessId = (uint)currentProcess.Id; - - MiniDumpExceptionInformation exp; - - exp.ThreadId = GetCurrentThreadId(); - exp.ClientPointers = false; - exp.ExceptionPointers = IntPtr.Zero; - - if (withException) + using (var currentProcess = Process.GetCurrentProcess()) { - exp.ExceptionPointers = marchal.GetExceptionPointers(); + var currentProcessHandle = currentProcess.Handle; + var currentProcessId = (uint)currentProcess.Id; + + MiniDumpExceptionInformation exp; + + exp.ThreadId = GetCurrentThreadId(); + exp.ClientPointers = false; + exp.ExceptionPointers = IntPtr.Zero; + + if (withException) + { + exp.ExceptionPointers = marchal.GetExceptionPointers(); + } + + var bRet = exp.ExceptionPointers == IntPtr.Zero + ? MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)options, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero) + : MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)options, ref exp, IntPtr.Zero, IntPtr.Zero); + + return bRet; } - - var bRet = exp.ExceptionPointers == IntPtr.Zero - ? MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint) options, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero) - : MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint) options, ref exp, IntPtr.Zero, IntPtr.Zero); - - return bRet; } public static bool Dump(IMarchal marchal, IHostingEnvironment hostingEnvironment, Option options = Option.WithFullMemory, bool withException = false) diff --git a/src/Umbraco.Infrastructure/Persistence/LocalDb.cs b/src/Umbraco.Infrastructure/Persistence/LocalDb.cs index 1a24a30066..0ca98d2b14 100644 --- a/src/Umbraco.Infrastructure/Persistence/LocalDb.cs +++ b/src/Umbraco.Infrastructure/Persistence/LocalDb.cs @@ -906,7 +906,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence return -1; } - var p = new Process + using (var p = new Process { StartInfo = { @@ -918,13 +918,15 @@ namespace Umbraco.Cms.Infrastructure.Persistence CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden } - }; - p.Start(); - output = p.StandardOutput.ReadToEnd(); - error = p.StandardError.ReadToEnd(); - p.WaitForExit(); + }) + { + p.Start(); + output = p.StandardOutput.ReadToEnd(); + error = p.StandardError.ReadToEnd(); + p.WaitForExit(); - return p.ExitCode; + return p.ExitCode; + } } /// diff --git a/src/Umbraco.Infrastructure/Sync/DatabaseServerMessenger.cs b/src/Umbraco.Infrastructure/Sync/DatabaseServerMessenger.cs index ee8793f5c9..10556b7fe6 100644 --- a/src/Umbraco.Infrastructure/Sync/DatabaseServerMessenger.cs +++ b/src/Umbraco.Infrastructure/Sync/DatabaseServerMessenger.cs @@ -72,15 +72,17 @@ namespace Umbraco.Cms.Infrastructure.Sync GlobalSettings = globalSettings.Value; _lastPruned = _lastSync = DateTime.UtcNow; _syncIdle = new ManualResetEvent(true); - - // See notes on _localIdentity - LocalIdentity = Environment.MachineName // eg DOMAIN\SERVER - + "/" + hostingEnvironment.ApplicationId // eg /LM/S3SVC/11/ROOT - + " [P" + Process.GetCurrentProcess().Id // eg 1234 - + "/D" + AppDomain.CurrentDomain.Id // eg 22 - + "] " + Guid.NewGuid().ToString("N").ToUpper(); // make it truly unique - + using (var process = Process.GetCurrentProcess()) + { + // See notes on _localIdentity + LocalIdentity = Environment.MachineName // eg DOMAIN\SERVER + + "/" + hostingEnvironment.ApplicationId // eg /LM/S3SVC/11/ROOT + + " [P" + process.Id // eg 1234 + + "/D" + AppDomain.CurrentDomain.Id // eg 22 + + "] " + Guid.NewGuid().ToString("N").ToUpper(); // make it truly unique + } _initialized = new Lazy(InitializeWithMainDom); + } public GlobalSettings GlobalSettings { get; }