예제 #1
0
        internal bool EndDispatchSession(IAsyncResult result)
        {
            try
            {
                DispatchSessionAsyncResult dispatchAsyncResult = DispatchSessionAsyncResult.End(result);
                if (dispatchAsyncResult.DuplicateSucceeded)
                {
                    OnDispatchSuccess();
                    return(true);
                }
            }
            catch (Exception exception)
            {
                EventLogEventId logEventId = EventLogEventId.MessageQueueDuplicatedSocketLeak;
                if (this.TransportType == TransportType.NamedPipe)
                {
                    logEventId = EventLogEventId.MessageQueueDuplicatedPipeLeak;
                }

                Debug.Print("WorkerProcess.DispatchSession() failed sending duplicated socket to processId: " + this.ProcessId + " exception:" + exception);
                DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error,
                                                    (ushort)EventLogCategory.SharingService,
                                                    (uint)logEventId,
                                                    this.ProcessId.ToString(NumberFormatInfo.InvariantInfo),
                                                    ListenerTraceUtility.CreateSourceString(this),
                                                    exception.ToString());

                if (Fx.IsFatal(exception))
                {
                    throw;
                }

                if (exception is FaultException && !AppSettings.FailOnConnectionDispatchFaults)
                {
                    // Something went wrong with establishing a connection from the duplicated handle on the service side
                    // The communication between SMSvcHost and the service host is still good so no need to tear down the
                    // connection because of a single bad connecting client.
                    return(false);
                }

                Close();

                // make sure we close the connection to the SharedConnectionListener
                // so it knows we've unregistered it
                ((IChannel)connectionDuplicator).Abort();

                if (!ShouldRecoverFromProxyCall(exception))
                {
                    throw;
                }
            }

            return(false);
        }
예제 #2
0
        internal bool EndDispatchSession(IAsyncResult result)
        {
            try
            {
                DispatchSessionAsyncResult dispatchAsyncResult = DispatchSessionAsyncResult.End(result);
                if (dispatchAsyncResult.DuplicateSucceeded)
                {
                    OnDispatchSuccess();
                    return(true);
                }
            }
            catch (Exception exception)
            {
                EventLogEventId logEventId = EventLogEventId.MessageQueueDuplicatedSocketLeak;
                if (this.TransportType == TransportType.NamedPipe)
                {
                    logEventId = EventLogEventId.MessageQueueDuplicatedPipeLeak;
                }

                Debug.Print("WorkerProcess.DispatchSession() failed sending duplicated socket to processId: " + this.ProcessId + " exception:" + exception);
                DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error,
                                                    (ushort)EventLogCategory.SharingService,
                                                    (uint)logEventId,
                                                    this.ProcessId.ToString(NumberFormatInfo.InvariantInfo),
                                                    ListenerTraceUtility.CreateSourceString(this),
                                                    exception.ToString());

                if (Fx.IsFatal(exception))
                {
                    throw;
                }

                Close();

                // make sure we close the connection to the SharedConnectionListener
                // so it knows we've unregistered it
                ((IChannel)connectionDuplicator).Abort();

                if (!ShouldRecoverFromProxyCall(exception))
                {
                    throw;
                }
            }

            return(false);
        }
예제 #3
0
        bool RegisterBindings(IActivatedMessageQueue queue, int siteId, string[] bindings, string path)
        {
            Debug.Print("ListenerAdapter[" + ProtocolName + "]::RegisterBindings() bindings#: " + bindings.Length);
            BaseUriWithWildcard[] baseAddresses = new BaseUriWithWildcard[bindings.Length];
            // first make sure all the bindings are valid for this protocol
            for (int i = 0; i < bindings.Length; i++)
            {
                string binding  = bindings[i];
                int    index    = binding.IndexOf(':');
                string protocol = binding.Substring(0, index);
                if (string.Compare(this.ProtocolName, protocol, StringComparison.OrdinalIgnoreCase) != 0)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                                  SR.GetString(SR.LAProtocolMismatch, protocol, path, this.ProtocolName)));
                }

                binding = binding.Substring(index + 1);
                try
                {
                    baseAddresses[i] = BaseUriWithWildcard.CreateHostedUri(ProtocolName, binding, path);
                    Debug.Print("ListenerAdapter[" + ProtocolName + "]::RegisterBindings() CreateUrlFromBinding(binding: " + binding + " path: " + path + ") returned baseAddress: " + baseAddresses[i]);
                }
                catch (UriFormatException exception)
                {
                    Debug.Print("ListenerAdapter[" + ProtocolName + "]::RegisterBindings() CreateUrlFromBinding(binding: " + binding + " path: " + path + ") failed with UriFormatException: " + exception.Message);
                    DiagnosticUtility.TraceHandledException(exception, TraceEventType.Error);

                    // We only log the event for the site root.
                    if (string.Compare(path, SiteRootPath, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error,
                                                            (ushort)EventLogCategory.ListenerAdapter,
                                                            (uint)EventLogEventId.BindingError,
                                                            protocol,
                                                            binding,
                                                            siteId.ToString(NumberFormatInfo.CurrentInfo),
                                                            bindings[i],
                                                            ListenerTraceUtility.CreateSourceString(this),
                                                            exception.ToString());
                    }

                    return(false);
                }
            }

            // now make sure all the bindings can be listened on or roll back
            for (int i = 0; i < bindings.Length; i++)
            {
                ListenerExceptionStatus status = ListenerExceptionStatus.FailedToListen;
                Exception exception            = null;
                try
                {
                    status = queue.Register(baseAddresses[i]);
                    Debug.Print("ListenerAdapter[" + ProtocolName + "]::RegisterBindings() registering baseAddress: " + baseAddresses[i] + " with queue returned: " + status);
                }
                catch (Exception ex)
                {
                    if (Fx.IsFatal(ex))
                    {
                        throw;
                    }

                    DiagnosticUtility.TraceHandledException(exception, TraceEventType.Error);

                    exception = ex;
                }

                if (status != ListenerExceptionStatus.Success)
                {
                    // We only log the event for the site root.
                    if (string.Compare(path, SiteRootPath, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error,
                                                            (ushort)EventLogCategory.ListenerAdapter,
                                                            (uint)EventLogEventId.LAFailedToListenForApp,
                                                            activationService.ActivationServiceName,
                                                            ProtocolName,
                                                            siteId.ToString(NumberFormatInfo.CurrentInfo),
                                                            baseAddresses[i].ToString(),
                                                            status.ToString(),
                                                            exception == null ? string.Empty : exception.ToString());
                    }

                    queue.UnregisterAll();
                    return(false);
                }
            }

            return(true);
        }