Пример #1
0
 // Token: 0x060010EC RID: 4332 RVA: 0x000461FF File Offset: 0x000443FF
 internal override void PassiveRecoveryActionInternal()
 {
     base.PostProcessingAction = delegate()
     {
         BugcheckHelper.TriggerBugcheckIfRequired(base.FailureItem.CreationTime.ToUniversalTime(), string.Format("HungIoExceededThresholdDoubleDiskTagHandler FailureItem at {0}", base.FailureItem.CreationTime));
     };
 }
        internal static Exception TryCrashingStoreGracefully()
        {
            Exception       ex                   = null;
            Process         storeProcess         = null;
            EventWaitHandle crashControlAckEvent = null;

            try
            {
                ReplayCrimsonEvents.InitiatingGracefulStoreCrash.Log();
                storeProcess = ServiceOperations.GetServiceProcess("MSExchangeIS", out ex);
                if (ex == null)
                {
                    ex = ServiceOperations.RunOperation(delegate(object param0, EventArgs param1)
                    {
                        if (!RegistryParameters.KillStoreInsteadOfWatsonOnTimeout)
                        {
                            crashControlAckEvent = new EventWaitHandle(false, EventResetMode.ManualReset, "Global\\17B584B2-A9E0-45CF-87CB-7774112D6CB9");
                            ThreadPool.QueueUserWorkItem(delegate(object param0)
                            {
                                Exception ex2 = ServiceOperations.ControlService("MSExchangeIS", 130);
                                if (ex2 != null)
                                {
                                    AmTrace.Debug("ControlService() failed with {0}", new object[]
                                    {
                                        ex2.Message
                                    });
                                }
                            });
                        }
                        else
                        {
                            AmTrace.Diagnostic("Killing store instead of taking a Watson dump due to registry override.", new object[0]);
                        }
                        if (crashControlAckEvent != null)
                        {
                            if (crashControlAckEvent.WaitOne(RegistryParameters.StoreCrashControlCodeAckTimeoutInMSec))
                            {
                                AmStoreServiceMonitor.ReportKillStarted();
                                Stopwatch stopwatch = new Stopwatch();
                                stopwatch.Start();
                                if (!storeProcess.WaitForExit(RegistryParameters.StoreWatsonDumpTimeoutInMSec))
                                {
                                    AmTrace.Diagnostic("Store process did not finish taking dump in {0} msecs", new object[]
                                    {
                                        RegistryParameters.StoreWatsonDumpTimeoutInMSec
                                    });
                                }
                                else
                                {
                                    AmTrace.Diagnostic("Store process finished taking dump in {0} msecs", new object[]
                                    {
                                        stopwatch.Elapsed.TotalMilliseconds
                                    });
                                }
                            }
                            else
                            {
                                AmTrace.Diagnostic("Store failed to acknowledge that it received the crash control code in {0} msecs.", new object[]
                                {
                                    RegistryParameters.StoreCrashControlCodeAckTimeoutInMSec
                                });
                                AmStoreServiceMonitor.ReportKillStarted();
                            }
                        }
                        else
                        {
                            AmStoreServiceMonitor.ReportKillStarted();
                        }
                        if (!storeProcess.HasExited)
                        {
                            if (crashControlAckEvent != null)
                            {
                                AmTrace.Diagnostic("Store process is still running even after the graceful attempt. Force killing it.", new object[0]);
                            }
                            storeProcess.Kill();
                            TimeSpan timeSpan = TimeSpan.FromMilliseconds((double)RegistryParameters.StoreKillBugcheckTimeoutInMSec);
                            if (!storeProcess.WaitForExit(RegistryParameters.StoreKillBugcheckTimeoutInMSec))
                            {
                                ExDateTime storeKillBugcheckDisabledTime = RegistryParameters.StoreKillBugcheckDisabledTime;
                                string text = string.Format("Store process is still running {0} secs after attempt to force kill it.", timeSpan.TotalSeconds);
                                if (storeKillBugcheckDisabledTime > ExDateTime.UtcNow)
                                {
                                    AmTrace.Debug("Store bugcheck has been disabled by regkey '{0}' until '{1}'.", new object[]
                                    {
                                        "StoreKillBugcheckDisabledTime",
                                        storeKillBugcheckDisabledTime
                                    });
                                    ReplayCrimsonEvents.StoreBugCheckDisabledUntilTime.LogPeriodic <string, string, ExDateTime>(Environment.MachineName, DiagCore.DefaultEventSuppressionInterval, text, "StoreKillBugcheckDisabledTime", storeKillBugcheckDisabledTime);
                                    return;
                                }
                                AmTrace.Debug("Attempting to bugcheck the system. Reason: {0}", new object[]
                                {
                                    text
                                });
                                BugcheckHelper.TriggerBugcheckIfRequired(DateTime.UtcNow, text);
                                return;
                            }
                            else
                            {
                                AmTrace.Diagnostic("Store process has been forcefully killed.", new object[0]);
                            }
                        }
                    });
                }
            }
            finally
            {
                ReplayCrimsonEvents.FinishedGracefulStoreCrash.Log <string>((ex != null) ? ex.Message : "<none>");
                if (crashControlAckEvent != null)
                {
                    crashControlAckEvent.Close();
                }
                if (storeProcess != null)
                {
                    storeProcess.Dispose();
                }
            }
            return(ex);
        }