public void UpdatePoisonNdrSentToTrue(SubmissionPoisonContext submissionPoisonContext)
 {
     this.resourceProtector.EnterReadLock();
     try
     {
         if (!this.loaded)
         {
             return;
         }
         ArgumentValidator.ThrowIfNull("submissionPoisonContext", submissionPoisonContext);
         ArgumentValidator.ThrowIfEmpty("submissionPoisonContext.ResourceGuid", submissionPoisonContext.ResourceGuid);
     }
     finally
     {
         this.resourceProtector.ExitReadLock();
     }
     this.resourceProtector.EnterWriteLock();
     try
     {
         if (this.submissionPoisonDataStore.ContainsKey(submissionPoisonContext.ResourceGuid) && this.submissionPoisonDataStore[submissionPoisonContext.ResourceGuid].ContainsKey(submissionPoisonContext.MapiEventCounter))
         {
             ResourceEventCounterCrashInfo resourceEventCounterCrashInfo = this.submissionPoisonDataStore[submissionPoisonContext.ResourceGuid][submissionPoisonContext.MapiEventCounter];
             resourceEventCounterCrashInfo.IsPoisonNdrSent = true;
             this.crashRepository.PersistCrashInfo(submissionPoisonContext.ResourceGuid, submissionPoisonContext.MapiEventCounter, resourceEventCounterCrashInfo, this.maxPoisonEntries);
         }
     }
     finally
     {
         this.resourceProtector.ExitWriteLock();
     }
 }
Exemplo n.º 2
0
        protected bool ProcessSingleEventCounterCrashInfoValue(string[] eventCounterCrashInfo, string eventCounterString, RegistryKey poisonKey, string resourceKeyString, TimeSpan crashExpiryWindow, out ResourceEventCounterCrashInfo resourceEventCounterCrashInfo)
        {
            ArgumentValidator.ThrowIfNull("eventCounterCrashInfo", eventCounterCrashInfo);
            ArgumentValidator.ThrowIfInvalidValue <int>("eventCounterCrashInfo", eventCounterCrashInfo.Length, (int length) => length == 2);
            resourceEventCounterCrashInfo = null;
            bool isPoisonNdrSent;
            SortedSet <DateTime> crashTimes;

            if (this.ParseSingleEventCounterNdrSentData(eventCounterCrashInfo[1], eventCounterString, poisonKey, resourceKeyString, out isPoisonNdrSent) && this.ProcessSingleEventCounterCrashTimeData(eventCounterCrashInfo[0], eventCounterString, poisonKey, resourceKeyString, crashExpiryWindow, out crashTimes))
            {
                resourceEventCounterCrashInfo = new ResourceEventCounterCrashInfo(crashTimes, isPoisonNdrSent);
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        public bool GetResourceCrashInfoData(Guid resourceGuid, TimeSpan crashExpiryWindow, out Dictionary <long, ResourceEventCounterCrashInfo> resourceCrashData, out SortedSet <DateTime> allCrashTimes)
        {
            ArgumentValidator.ThrowIfEmpty("resourceGuid", resourceGuid);
            string text = resourceGuid.ToString();

            resourceCrashData = new Dictionary <long, ResourceEventCounterCrashInfo>();
            allCrashTimes     = new SortedSet <DateTime>();
            try
            {
                using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(string.Format(RegistryCrashRepository.poisonInfoKeyLocationFromRoot, this.poisonRegistryEntryLocation, text), RegistryKeyPermissionCheck.ReadWriteSubTree))
                {
                    if (registryKey != null)
                    {
                        foreach (string text2 in registryKey.GetValueNames())
                        {
                            if (string.IsNullOrEmpty(text2))
                            {
                                registryKey.DeleteValue(text2, false);
                            }
                            else
                            {
                                ResourceEventCounterCrashInfo resourceEventCounterCrashInfo = null;
                                long num;
                                if (this.ProcessEventCounterData(text2, registryKey, text, out num))
                                {
                                    string[] eventCounterCrashInfo = null;
                                    if (this.GetEventCounterCrashInfoValue(text2, registryKey, text, out eventCounterCrashInfo) && this.ProcessSingleEventCounterCrashInfoValue(eventCounterCrashInfo, text2, registryKey, text, crashExpiryWindow, out resourceEventCounterCrashInfo))
                                    {
                                        resourceCrashData.Add(num, resourceEventCounterCrashInfo);
                                        allCrashTimes.UnionWith(resourceEventCounterCrashInfo.CrashTimes);
                                        this.AddDataToPurgeDictionary(resourceGuid, num, resourceEventCounterCrashInfo.CrashTimes.Max);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                StoreDriverSubmission.LogEvent(MSExchangeStoreDriverSubmissionEventLogConstants.Tuple_PoisonMessageLoadFailedRegistryAccessDenied, null, new object[]
                {
                    ex.Message
                });
                throw new CrashRepositoryAccessException(Strings.PoisonMessageRegistryAccessFailed, ex);
            }
            return(resourceCrashData.Count != 0);
        }
 public void SavePoisonContext(SubmissionPoisonContext submissionPoisonContext)
 {
     this.resourceProtector.EnterReadLock();
     try
     {
         if (!this.loaded)
         {
             return;
         }
         if (submissionPoisonContext == null || submissionPoisonContext.ResourceGuid == Guid.Empty)
         {
             this.storeDriverTracer.GeneralTracer.TracePass(this.storeDriverTracer.MessageProbeActivityId, 0L, "Poison context information cannot be store on the crashing thread. Exiting...");
             return;
         }
     }
     finally
     {
         this.resourceProtector.ExitReadLock();
     }
     this.resourceProtector.EnterWriteLock();
     try
     {
         ResourceEventCounterCrashInfo resourceEventCounterCrashInfo;
         if (this.submissionPoisonDataStore.ContainsKey(submissionPoisonContext.ResourceGuid) && this.submissionPoisonDataStore[submissionPoisonContext.ResourceGuid].ContainsKey(submissionPoisonContext.MapiEventCounter))
         {
             resourceEventCounterCrashInfo = this.submissionPoisonDataStore[submissionPoisonContext.ResourceGuid][submissionPoisonContext.MapiEventCounter];
         }
         else
         {
             resourceEventCounterCrashInfo = new ResourceEventCounterCrashInfo(new SortedSet <DateTime>(), false);
         }
         resourceEventCounterCrashInfo.CrashTimes.Add(DateTime.UtcNow);
         try
         {
             this.crashRepository.PersistCrashInfo(submissionPoisonContext.ResourceGuid, submissionPoisonContext.MapiEventCounter, resourceEventCounterCrashInfo, this.maxPoisonEntries);
         }
         catch (CrashRepositoryAccessException)
         {
         }
     }
     finally
     {
         this.resourceProtector.ExitWriteLock();
     }
 }
Exemplo n.º 5
0
 public void PersistCrashInfo(Guid resourceGuid, long eventCounter, ResourceEventCounterCrashInfo resourceEventCounterCrashInfo, int maxCrashEntries)
 {
     ArgumentValidator.ThrowIfEmpty("resourceGuid", resourceGuid);
     ArgumentValidator.ThrowIfNull("resourceEventCounterCrashInfo", resourceEventCounterCrashInfo);
     ArgumentValidator.ThrowIfZeroOrNegative("maxCrashEntries", maxCrashEntries);
     try
     {
         using (RegistryKey registryKey = Registry.LocalMachine.CreateSubKey(string.Format(RegistryCrashRepository.poisonInfoKeyLocationFromRoot, this.poisonRegistryEntryLocation, resourceGuid)))
         {
             this.PersistCrashInfoToRegistry(registryKey, resourceGuid, eventCounter, resourceEventCounterCrashInfo, maxCrashEntries);
         }
     }
     catch (UnauthorizedAccessException ex)
     {
         StoreDriverSubmission.LogEvent(MSExchangeStoreDriverSubmissionEventLogConstants.Tuple_PoisonMessageSaveFailedRegistryAccessDenied, null, new object[]
         {
             ex.Message
         });
         throw new CrashRepositoryAccessException(Strings.PoisonMessageRegistryAccessFailed, ex);
     }
 }
Exemplo n.º 6
0
        protected void PersistCrashInfoToRegistry(RegistryKey resourcePoisonKey, Guid resourceGuid, long eventCounter, ResourceEventCounterCrashInfo resourceEventCounterCrashInfo, int maxCrashEntries)
        {
            StringBuilder stringBuilder = new StringBuilder();

            foreach (DateTime dateTime in resourceEventCounterCrashInfo.CrashTimes)
            {
                stringBuilder.Append(dateTime + ";");
            }
            if (stringBuilder.Length > 0)
            {
                stringBuilder.Remove(stringBuilder.Length - 1, 1);
            }
            string text = eventCounter.ToString();

            if (this.PurgeRegistryEntriesIfNecessary(resourceGuid.ToString(), text, maxCrashEntries))
            {
                this.AddDataToPurgeDictionary(resourceGuid, eventCounter, resourceEventCounterCrashInfo.CrashTimes.Max);
            }
            resourcePoisonKey.SetValue(text, new string[]
            {
                stringBuilder.ToString(),
                resourceEventCounterCrashInfo.IsPoisonNdrSent.ToString()
            }, RegistryValueKind.MultiString);
        }