예제 #1
0
        // Token: 0x0600000A RID: 10 RVA: 0x00002730 File Offset: 0x00000930
        private static void MainUnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs eventArgs)
        {
            MailboxTransportDeliveryService.diag.TraceDebug(0L, "MainUnhandledExceptionHandler");
            if (MailboxTransportDeliveryService.isExiting)
            {
                Environment.Exit(0);
            }
            if (Components.IsActive)
            {
                Components.OnUnhandledException((Exception)eventArgs.ExceptionObject);
                PoisonMessage.SavePoisonContext((Exception)eventArgs.ExceptionObject);
                DeliveryConfiguration.Instance.PoisonHandler.SavePoisonContext();
                MailboxTransportEventLogger.LogEvent(MSExchangeDeliveryEventLogConstants.Tuple_DeliveryPoisonMessage, null, new string[]
                {
                    PoisonHandler <DeliveryPoisonContext> .Context.ToString(),
                    eventArgs.ExceptionObject.ToString()
                });
            }
            int num = Interlocked.Exchange(ref MailboxTransportDeliveryService.busyUnhandledException, 1);

            if (num == 1)
            {
                return;
            }
            ExWatson.HandleException(sender, eventArgs);
            MailboxTransportDeliveryService.diag.TraceDebug(0L, "Done processing unhandled exception. Return to CLR.");
        }
예제 #2
0
        // Token: 0x06000006 RID: 6 RVA: 0x00002558 File Offset: 0x00000758
        protected override void OnStopInternal()
        {
            MailboxTransportDeliveryService.LogStage(MailboxTransportDeliveryService.Stage.StopService);
            MailboxTransportDeliveryService.isExiting = true;
            ADNotificationListener.Stop();
            MailboxTransportDeliveryService.diag.TraceDebug <DateTime>(0L, "Stopping MailTransportDeliveryService ({0})", DateTime.UtcNow);
            bool flag = false;

            try
            {
                MailboxTransportDeliveryService.LogStage(MailboxTransportDeliveryService.Stage.StopBackgroundThread);
                if (MailboxTransportDeliveryService.backgroundThread != null)
                {
                    MailboxTransportDeliveryService.backgroundThread.Stop();
                }
                if (this.isDiagnosticHandlerRegisteredForSettingOverrideSync)
                {
                    try
                    {
                        ProcessAccessManager.UnregisterComponent(SettingOverrideSync.Instance);
                    }
                    catch (RpcException ex)
                    {
                        MailboxTransportDeliveryService.diag.TraceError <string>(0L, "Failed to unregister SettingOverride component with Rpc Server. Error : {0}", ex.ToString());
                    }
                }
                SettingOverrideSync.Instance.Stop();
                MailboxTransportDeliveryService.LogStage(MailboxTransportDeliveryService.Stage.StopMessageTracking);
                MessageTrackingLog.Stop();
                MailboxTransportDeliveryService.LogStage(MailboxTransportDeliveryService.Stage.StopConfiguration);
                DeliveryConfiguration.Instance.Unload();
                MailboxTransportEventLogger.LogEvent(MSExchangeDeliveryEventLogConstants.Tuple_DeliveryServiceStopSuccess, null, new string[0]);
                MailboxTransportDeliveryService.diag.TraceDebug(0L, "Stopped MailboxDeliveryService");
                MailboxTransportDeliveryService.LogStage(MailboxTransportDeliveryService.Stage.UngregisterPamComponent);
                ProcessAccessManager.UnregisterComponent(this);
                MailboxTransportDeliveryService.LogStage(MailboxTransportDeliveryService.Stage.ServiceStopped);
                flag = true;
            }
            finally
            {
                if (!flag)
                {
                    MailboxTransportEventLogger.LogEvent(MSExchangeDeliveryEventLogConstants.Tuple_DeliveryServiceStopFailure, null, new string[0]);
                    MailboxTransportDeliveryService.diag.TraceError(0L, "Failed to stop MailboxDeliveryService");
                }
            }
            DeliveryThrottling.Instance.Dispose();
        }
예제 #3
0
        // Token: 0x06000002 RID: 2 RVA: 0x000020F8 File Offset: 0x000002F8
        public static void Main(string[] args)
        {
            CommonDiagnosticsLog.Initialize(HostId.MailboxDeliveryService);
            MailboxTransportDeliveryService.LogStage(MailboxTransportDeliveryService.Stage.StartProcess);
            int num = Privileges.RemoveAllExcept(new string[]
            {
                "SeAuditPrivilege",
                "SeChangeNotifyPrivilege",
                "SeCreateGlobalPrivilege"
            });

            if (num != 0)
            {
                Environment.Exit(num);
            }
            MailboxTransportDeliveryService.LogStage(MailboxTransportDeliveryService.Stage.RegisterWatson);
            ExWatson.Init("E12IIS");
            AppDomain.CurrentDomain.UnhandledException += MailboxTransportDeliveryService.MainUnhandledExceptionHandler;
            MailboxTransportDeliveryService.LogStage(MailboxTransportDeliveryService.Stage.RegisterWatsonAction);
            ExWatson.RegisterReportAction(new WatsonRegKeyReportAction(MailboxTransportDeliveryService.watsonRegKeyReportActionString), WatsonActionScope.Process);
            MailboxTransportDeliveryService.runningAsService = !Environment.UserInteractive;
            bool flag  = false;
            bool flag2 = false;

            foreach (string text in args)
            {
                if (text.StartsWith("-?", StringComparison.Ordinal))
                {
                    MailboxTransportDeliveryService.Usage();
                    Environment.Exit(0);
                }
                else if (text.StartsWith("-console"))
                {
                    flag = true;
                }
                else if (text.StartsWith("-wait"))
                {
                    flag2 = true;
                }
            }
            if (!MailboxTransportDeliveryService.runningAsService)
            {
                if (!flag)
                {
                    MailboxTransportDeliveryService.Usage();
                    Environment.Exit(0);
                }
                Console.WriteLine("Starting {0}, running in console mode.", Assembly.GetExecutingAssembly().GetName().Name);
                if (flag2)
                {
                    Console.WriteLine("Press ENTER to continue.");
                    Console.ReadLine();
                }
            }
            MailboxTransportDeliveryService.LogStage(MailboxTransportDeliveryService.Stage.InitializePerformanceCounterInstance);
            Globals.InitializeSinglePerfCounterInstance();
            SettingOverrideSync.Instance.Start(true);
            MailboxTransportDeliveryService.LogStage(MailboxTransportDeliveryService.Stage.LoadTransportAppConfig);
            string text2;

            if (!Components.TryLoadTransportAppConfig(out text2))
            {
                MailboxTransportEventLogger.LogEvent(MSExchangeDeliveryEventLogConstants.Tuple_DeliveryServiceStartFailure, null, new string[]
                {
                    text2
                });
                MailboxTransportDeliveryService.PublishServiceStartFailureNotification(text2);
                Environment.Exit(1);
            }
            MailboxTransportDeliveryService.LogStage(MailboxTransportDeliveryService.Stage.CreateService);
            MailboxTransportDeliveryService.mailboxTransportDeliveryService = new MailboxTransportDeliveryService();
            if (!MailboxTransportDeliveryService.runningAsService)
            {
                ExServiceBase.RunAsConsole(MailboxTransportDeliveryService.mailboxTransportDeliveryService);
                return;
            }
            ServiceBase.Run(MailboxTransportDeliveryService.mailboxTransportDeliveryService);
        }
예제 #4
0
        // Token: 0x06000005 RID: 5 RVA: 0x00002340 File Offset: 0x00000540
        protected override void OnStartInternal(string[] args)
        {
            MailboxTransportDeliveryService.LogStage(MailboxTransportDeliveryService.Stage.StartService);
            MailboxTransportDeliveryService.diag.TracePfd <int, DateTime>(0L, "PFD EMS {0} Starting MailboxDeliveryService ({1})", 24475, DateTime.UtcNow);
            bool   flag  = false;
            bool   flag2 = false;
            string text  = string.Empty;

            try
            {
                MailboxTransportDeliveryService.LogStage(MailboxTransportDeliveryService.Stage.RegisterPamComponent);
                ProcessAccessManager.RegisterComponent(this);
                MailboxTransportDeliveryService.LogStage(MailboxTransportDeliveryService.Stage.StartMessageTracking);
                MessageTrackingLog.Start("MSGTRKMD");
                MailboxTransportDeliveryService.LogStage(MailboxTransportDeliveryService.Stage.LoadConfiguration);
                StorageExceptionHandler.Init();
                DeliveryConfiguration.Instance.Load(MailboxTransportDeliveryService.messageListener);
                try
                {
                    ProcessAccessManager.RegisterComponent(SettingOverrideSync.Instance);
                    this.isDiagnosticHandlerRegisteredForSettingOverrideSync = true;
                }
                catch (RpcException ex)
                {
                    MailboxTransportDeliveryService.diag.TraceError <string>(0L, "Failed to register SettingOverride component with Rpc Server. Error : {0}", ex.ToString());
                }
                MailboxTransportDeliveryService.LogStage(MailboxTransportDeliveryService.Stage.StartBackgroundThread);
                MailboxTransportDeliveryService.backgroundThread = new BackgroundThreadDelivery();
                MailboxTransportDeliveryService.backgroundThread.Start(false, ServiceState.Active);
                MailboxTransportEventLogger.LogEvent(MSExchangeDeliveryEventLogConstants.Tuple_DeliveryServiceStartSuccess, null, new string[0]);
                MailboxTransportDeliveryService.LogStage(MailboxTransportDeliveryService.Stage.ServiceStarted);
                MailboxTransportDeliveryService.diag.TracePfd <int>(0L, "PFD EMS {0} MailTransportDeliveryService Started", 26523);
                flag = true;
            }
            catch (ADTransientException ex2)
            {
                MailboxTransportDeliveryService.diag.TraceError <string>(0L, "Failed to start MailboxDeliveryService. Error: {0}", ex2.ToString());
                MailboxTransportEventLogger.LogEvent(MSExchangeDeliveryEventLogConstants.Tuple_DeliveryServiceStartFailure, null, new string[]
                {
                    ex2.ToString()
                });
                MailboxTransportDeliveryService.PublishServiceStartFailureNotification(ex2.Message);
                Environment.Exit(1);
            }
            catch (ConfigurationErrorsException ex3)
            {
                text  = ex3.Message;
                flag2 = true;
            }
            catch (HandlerParseException ex4)
            {
                text  = ex4.Message;
                flag2 = true;
            }
            finally
            {
                if (!flag)
                {
                    MailboxTransportEventLogger.LogEvent(MSExchangeDeliveryEventLogConstants.Tuple_DeliveryServiceStartFailure, null, new string[]
                    {
                        text
                    });
                    MailboxTransportDeliveryService.PublishServiceStartFailureNotification(text);
                    MailboxTransportDeliveryService.diag.TraceError(0L, "Failed to start MailboxDeliveryService");
                    if (flag2)
                    {
                        base.Stop();
                    }
                }
            }
        }