protected override void OnStart(string[] args) { try { if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.ServiceStart, SR.GetString(SR.TraceCodeServiceStart), this); } #if DEBUG if (DebuggableService.DelayStart(ServiceName)) { (new Thread(new ThreadStart(Start))).Start(); return; } #endif Start(); } catch (Exception exception) { // Log the error to eventlog. ListenerTraceUtility.EventLog.LogEvent(TraceEventType.Error, (ushort)System.Runtime.Diagnostics.EventLogCategory.ListenerAdapter, (uint)System.Runtime.Diagnostics.EventLogEventId.ServiceStartFailed, false, exception.ToString()); throw; } }
internal void OnDupHandle(ListenerSessionConnection session) { if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.TransportListenerSessionsReceived, SR.GetString(SR.TraceCodeTransportListenerSessionsReceived), this); } if (TD.TransportListenerSessionsReceivedIsEnabled()) { TD.TransportListenerSessionsReceived(session.EventTraceActivity, session.Via.ToString()); } IPAddress address; int port; TransportType transportType = GetTransportTypeAndAddress(session.Connection, out address, out port); Debug.Print("TransportListener.OnDupHandle() via: " + session.Via.ToString() + " transportType: " + transportType); MessageQueue messageQueue = RoutingTable.Lookup(session.Via, address, port); if (messageQueue != null) { messageQueue.EnqueueSessionAndDispatch(session); } else { TransportListener.SendFault(session.Connection, FramingEncodingString.EndpointNotFoundFault); MessageQueue.OnDispatchFailure(transportType); } }
void Shutdown() { try { if (sharedMemory != null) { sharedMemory.Dispose(); } MessageQueue.CloseAll(transportType); } #pragma warning suppress 56500 // Microsoft, catch block unconditionally fails fast catch (Exception exception) { if (DiagnosticUtility.ShouldTraceError) { ListenerTraceUtility.TraceEvent(TraceEventType.Error, ListenerTraceCode.ServiceShutdownError, SR.GetString(SR.TraceCodeServiceShutdownError), this, exception); } if (Fx.IsFatal(exception)) { throw; } // We exit the service gracefully so that other services that share the process will not be affected. } finally { if (controlServiceHost != null) { controlServiceHost.Abort(); } } }
internal static void Stop(IPEndPoint endPoint) { lock (tcpInstances) { TransportListener t = tcpInstances[endPoint] as TransportListener; if (t != null) { if (t.DelRef() == 0) { if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.TransportListenerStop, SR.GetString(SR.TraceCodeTransportListenerStop), t); } try { t.Stop(); } finally { tcpInstances.Remove(endPoint); } } } } }
void CloseAllListenerChannelInstances(App app) { int hresult = CloseAllListenerChannelInstances(app.AppPool.AppPoolId, app.MessageQueue.ListenerChannelContext.ListenerChannelId); Debug.Print("ListenerAdapter[" + ProtocolName + "]::CloseAllListenerChannelInstances(" + app.AppKey + ") returned: " + hresult); if (hresult == 0) { if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.WasCloseAllListenerChannelInstances, SR.GetString(SR.TraceCodeWasCloseAllListenerChannelInstances), this); } if (TD.WasCloseAllListenerChannelInstancesCompletedIsEnabled()) { //WasWebHostAPI TD.WasCloseAllListenerChannelInstancesCompleted(this.EventTraceActivity); } } else { if (DiagnosticUtility.ShouldTraceError) { ListenerTraceUtility.TraceEvent(TraceEventType.Error, ListenerTraceCode.WasWebHostAPIFailed, SR.GetString(SR.TraceCodeWasWebHostAPIFailed), new StringTraceRecord("HRESULT", SR.GetString(SR.TraceCodeWasWebHostAPIFailed, "WebhostCloseAllListenerChannelInstances", hresult.ToString(CultureInfo.CurrentCulture))), this, null); } if (TD.WasCloseAllListenerChannelInstancesFailedIsEnabled()) { //WasWebHostAPIFailed TD.WasCloseAllListenerChannelInstancesFailed(this.EventTraceActivity, hresult.ToString(CultureInfo.CurrentCulture)); } } }
protected override void OnContinue() { if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.ServiceContinue, SR.GetString(SR.TraceCodeServiceContinue), this); } serviceCore.OnContinue(); }
void StartControlService() { controlServiceHost = null; Exception lastException = null; for (int iteration = 0; iteration < ListenerConstants.MaxRetries; iteration++) { controlServiceGuid = Guid.NewGuid(); string listenerEndPoint = controlServiceGuid.ToString(); try { Type contractType; if (transportType == TransportType.Tcp) { contractType = typeof(TcpWorkerProcess); } else { contractType = typeof(NamedPipeWorkerProcess); } ServiceHost typedServiceHost = new ServiceHost(contractType, Utility.FormatListenerEndpoint(serviceName, listenerEndPoint)); typedServiceHost.ServiceThrottle.MaxConcurrentSessions = ListenerConstants.RegistrationMaxConcurrentSessions; typedServiceHost.Description.Behaviors.Remove(typeof(ServiceMetadataBehavior)); typedServiceHost.AddServiceEndpoint(typeof(IConnectionRegister), CreateRegisterBinding(this.transportType), string.Empty); controlServiceHost = typedServiceHost; controlServiceHost.Open(); break; } catch (CommunicationException exception) { if (TD.ServiceStartPipeErrorIsEnabled()) { Uri formattedUri = Utility.FormatListenerEndpoint(serviceName, listenerEndPoint); TD.ServiceStartPipeError((formattedUri != null) ? formattedUri.ToString() : string.Empty); } if (DiagnosticUtility.ShouldTraceWarning) { ListenerTraceUtility.TraceEvent(TraceEventType.Warning, ListenerTraceCode.ServiceStartPipeError, SR.GetString(SR.TraceCodeServiceStartPipeError), this, exception); } lastException = exception; controlServiceHost = null; } } if (controlServiceHost == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new InvalidOperationException(SR.GetString(SR.ServiceStartErrorEndpoint, this.serviceName), lastException)); } }
protected override void OnStop() { if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.ServiceStop, SR.GetString(SR.TraceCodeServiceStop), this); } Shutdown(); }
protected override void OnPause() { if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.ServicePause, SR.GetString(SR.TraceCodeServicePause), this); } isPaused = true; }
protected override void OnPause() { if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.ServicePause, SR.GetString(SR.TraceCodeServicePause), this); } this.integrationActivationService.Paused = true; this.transportActivationService.Paused = true; }
protected override void OnStop() { if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.ServiceStop, SR.GetString(SR.TraceCodeServiceStop), this); } base.RequestAdditionalTime(ListenerConstants.ServiceStopTimeout); serviceCore.OnStop(); }
internal static MessageQueue Lookup(Uri uri, IPAddress address, int port) { if (TD.RoutingTableLookupStartIsEnabled()) { TD.RoutingTableLookupStart(); } Uri wildCardUri = uri; UriPrefixTable <MessageQueueAndPath> table = namedPipeMessageQueues; if (address != null) { // Including port number to support TCP proxy (see MB56472). We only use it for wildcard matching below. // NOTE: we don't need to call TcpChannelListener.FixIpv6Hostname to fix the host name because it's ignored anyway. UriBuilder uriBuilder = new UriBuilder(uri.Scheme, uri.Host, port, uri.PathAndQuery); wildCardUri = uriBuilder.Uri; table = tcpMessageQueues; } MessageQueueAndPath found = null; bool success = table.TryLookupUri(wildCardUri, HostNameComparisonMode.StrongWildcard, out found); if (success && address != null) { success = ValidateAddress(address, ref found); } if (!success) { success = table.TryLookupUri(uri, HostNameComparisonMode.Exact, out found); if (success && address != null) { success = ValidateAddress(address, ref found); } } if (!success) { success = table.TryLookupUri(wildCardUri, HostNameComparisonMode.WeakWildcard, out found); if (success && address != null) { success = ValidateAddress(address, ref found); } } if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.RoutingTableLookup, SR.GetString(SR.TraceCodeRoutingTableLookup), new StringTraceRecord("Uri", uri.ToString()), null, null); } Debug.Print("RoutingTable.Lookup(" + uri + ") matched: " + (found == null ? "<NoMatch!>" : found.Uri.ToString())); if (TD.RoutingTableLookupStopIsEnabled()) { TD.RoutingTableLookupStop(); } return(found == null ? null : found.MessageQueue); }
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); }
protected override DuplicateContext DuplicateConnection(ListenerSessionConnection session) { SocketInformation dupedSocket = default(SocketInformation); try { dupedSocket = (SocketInformation)session.Connection.DuplicateAndClose(this.ProcessId); } #pragma warning suppress 56500 // covered by FxCOP catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } // this normally happens if: // A) we don't have rights to duplicate handles to the WorkerProcess NativeErrorCode == 10022 // B) we fail to duplicate handle because the WorkerProcess is exiting/exited NativeErrorCode == 10024 // - in the self hosted case: report error to the client // - in the web hosted case: roundrobin to the next available WorkerProcess (if this WorkerProcess is down?) #if DEBUG if (exception is SocketException) { Debug.Print("TcpWorkerProcess.DuplicateConnection() failed duplicating socket for processId: " + this.ProcessId + " errorCode:" + ((SocketException)exception).NativeErrorCode + " exception:" + exception.Message); } #endif if (DiagnosticUtility.ShouldTraceError) { ListenerTraceUtility.TraceEvent(TraceEventType.Error, ListenerTraceCode.MessageQueueDuplicatedSocketError, SR.GetString(SR.TraceCodeMessageQueueDuplicatedSocketError), this, exception); } if (TD.MessageQueueDuplicatedSocketErrorIsEnabled()) { TD.MessageQueueDuplicatedSocketError(session.EventTraceActivity); } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ServiceActivationException(SR.GetString(SR.MessageQueueDuplicatedSocketError), exception)); } if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.MessageQueueDuplicatedSocket, SR.GetString(SR.TraceCodeMessageQueueDuplicatedSocket), this); } if (TD.MessageQueueDuplicatedSocketCompleteIsEnabled()) { TD.MessageQueueDuplicatedSocketComplete(session.EventTraceActivity); } return(new TcpDuplicateContext(dupedSocket, session.Via, session.Data)); }
internal static ListenerExceptionStatus Register(BaseUriWithWildcard path, WorkerProcess worker) { MessageQueue queue = null; lock (registry) { if (registry.TryGetValue(path, out queue)) { if (!queue.CanShare) { return(ListenerExceptionStatus.ConflictingRegistration); } } else { queue = new MessageQueue(); ListenerExceptionStatus status = ListenerExceptionStatus.FailedToListen; try { status = queue.Register(path); } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } if (DiagnosticUtility.ShouldTraceError) { ListenerTraceUtility.TraceEvent(TraceEventType.Error, ListenerTraceCode.RoutingTableCannotListen, SR.GetString(SR.TraceCodeRoutingTableCannotListen), new StringTraceRecord("Path", path.ToString()), null, exception); } } if (status != ListenerExceptionStatus.Success) { // not setting the worker.queue is not a problem, since we can't use this WorkerProcess return(status); } registry.Add(path, queue); } } queue.OnNewWorkerAvailable(worker); return(ListenerExceptionStatus.Success); }
protected void Close() { Debug.Print("MessageQueue.Close()"); // this is only called when all the workers are done // with I/O (they could be in the process of closing) lock (instances) { instances.Remove(this); } CloseCore(); if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.MessageQueueClosed, SR.GetString(SR.TraceCodeMessageQueueClosed), this); } }
protected override void OnStart(string[] args) { if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.ServiceStart, SR.GetString(SR.TraceCodeServiceStart), this); } #if DEBUG if (DebuggableService.DelayStart(ServiceName)) { (new Thread(new ThreadStart(Start))).Start(); return; } #endif Start(); }
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); }
protected override void OnConfigManagerConnected() { Debug.Print("ListenerAdapter[" + ProtocolName + "]::OnConfigManagerConnected()"); if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.WasConnected, SR.GetString(SR.TraceCodeWasConnected), this); } if (TD.WasConnectedIsEnabled()) { TD.WasConnected(this.EventTraceActivity); } if (wasConnected != null) { wasConnected.Set(); } }
void CloseCore() { Debug.Print("MessageQueue.CloseCore()"); UnregisterAll(); DropPendingMessages(false); lock (registry) { foreach (WorkerProcess worker in workers.ToArray()) { worker.Close(); } workers.Clear(); } if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.MessageQueueClosed, SR.GetString(SR.TraceCodeMessageQueueClosed), this); } }
protected override DuplicateContext DuplicateConnection(ListenerSessionConnection session) { IntPtr dupedPipe = IntPtr.Zero; try { dupedPipe = (IntPtr)session.Connection.DuplicateAndClose(this.ProcessId); } #pragma warning suppress 56500 // covered by FxCOP catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } // this normally happens if: // A) we don't have rights to duplicate handles to the WorkerProcess NativeErrorCode == 87 // B) we fail to duplicate handle because the WorkerProcess is exiting/exited NativeErrorCode == ??? // - in the self hosted case: report error to the client // - in the web hosted case: roundrobin to the next available WorkerProcess (if this WorkerProcess is down?) #if DEBUG if (exception is CommunicationException) { int errorCode = ((System.IO.PipeException)exception.InnerException).ErrorCode; Debug.Print("NamedPipeWorkerProcess.DuplicateConnection() failed duplicating pipe for processId: " + this.ProcessId + " errorCode:" + errorCode + " exception:" + exception.Message); } #endif if (DiagnosticUtility.ShouldTraceError) { ListenerTraceUtility.TraceEvent(TraceEventType.Error, ListenerTraceCode.MessageQueueDuplicatedPipe, SR.GetString(SR.TraceCodeMessageQueueDuplicatedPipe), this, exception); } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ServiceActivationException(SR.GetString(SR.MessageQueueDuplicatedPipeError), exception)); } if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.MessageQueueDuplicatedPipe, SR.GetString(SR.TraceCodeMessageQueueDuplicatedPipe), this); } return(new NamedPipeDuplicateContext(dupedPipe, session.Via, session.Data)); }
public DispatchSessionAsyncResult(ListenerSessionConnection session, AsyncCallback callback, object state) : base(callback, state) { this.session = session; DuplicateContext duplicateContext = null; try { duplicateContext = session.WorkerProcess.DuplicateConnection(session); } catch (ServiceActivationException e) { int traceCode; string traceDescription; if (session.WorkerProcess is TcpWorkerProcess) { traceCode = ListenerTraceCode.MessageQueueDuplicatedSocketError; traceDescription = SR.GetString(SR.TraceCodeMessageQueueDuplicatedSocketError); } else { traceCode = ListenerTraceCode.MessageQueueDuplicatedPipeError; traceDescription = SR.GetString(SR.TraceCodeMessageQueueDuplicatedPipeError); } if (DiagnosticUtility.ShouldTraceError) { ListenerTraceUtility.TraceEvent(TraceEventType.Error, traceCode, traceDescription, this, e); } this.Complete(true, e); return; } IAsyncResult result = this.session.WorkerProcess.ConnectionDuplicator.BeginDuplicate(duplicateContext, dispatchSessionCallback, this); if (result.CompletedSynchronously) { CompleteDuplicateSession(result); this.Complete(true); } }
void Unregister(BaseUriWithWildcard path) { Fx.Assert(paths.Contains(path), "Unregister: unregistering an unregistered path"); if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.MessageQueueUnregisterSucceeded, SR.GetString(SR.TraceCodeMessageQueueUnregisterSucceeded), new StringTraceRecord("Path", path.ToString()), this, null); } if (TD.MessageQueueUnregisterSucceededIsEnabled()) { TD.MessageQueueUnregisterSucceeded(this.EventTraceActivity, path.ToString()); } RoutingTable.Stop(this, path); IncrementUrisUnregisteredCounters(); OnUnregisterCompleted(); registry.Remove(path); paths.Remove(path); }
public static void EnsureInitializedForNetPipe() { EnsureInitializedForDiagnostics(); if (pipeData == null) { lock (SyncRoot) { if (pipeData == null) { pipeData = new NetPipeSectionData(); } } } if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.ReadNetPipeConfig, SR.GetString(SR.TraceCodeReadNetPipeConfig, pipeData.MaxPendingConnections, pipeData.MaxPendingAccepts, pipeData.ReceiveTimeout), null); } }
public static void EnsureInitializedForNetTcp() { EnsureInitializedForDiagnostics(); if (tcpData == null) { lock (SyncRoot) { if (tcpData == null) { tcpData = new NetTcpSectionData(); } } } if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.ReadNetTcpConfig, SR.GetString(SR.TraceCodeReadNetTcpConfig, tcpData.ListenBacklog, tcpData.MaxPendingConnections, tcpData.MaxPendingAccepts, tcpData.ReceiveTimeout, tcpData.TeredoEnabled), null); } }
static ListenerExceptionStatus TcpStart(MessageQueue messageQueue, BaseUriWithWildcard path) { int encodedSize = System.Text.Encoding.UTF8.GetByteCount(path.BaseAddress.AbsoluteUri); if (encodedSize > ListenerConstants.MaxUriSize) { if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.RoutingTablePathTooLong, SR.GetString(SR.TraceCodeRoutingTablePathTooLong), new StringTraceRecord("Path", path.ToString()), null, null); } return(ListenerExceptionStatus.PathTooLong); } IPEndPoint endPoint = GetEndPoint(path.BaseAddress); lock (tcpMessageQueues) { if (tcpMessageQueues.IsRegistered(path)) { if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.RoutingTableNamespaceConflict, SR.GetString(SR.TraceCodeRoutingTableNamespaceConflict), new StringTraceRecord("Path", path.ToString()), null, null); } return(ListenerExceptionStatus.ConflictingRegistration); } TransportListener.Listen(endPoint); tcpMessageQueues.RegisterUri(path.BaseAddress, path.HostNameComparisonMode, new MessageQueueAndPath(messageQueue, path.BaseAddress)); } if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.RoutingTableRegisterSuccess, SR.GetString(SR.TraceCodeRoutingTableRegisterSuccess), new StringTraceRecord("Path", path.ToString()), null, null); } return(ListenerExceptionStatus.Success); }
internal static void Stop(BaseUriWithWildcard pipeUri) { lock (namedPipeInstances) { TransportListener t = namedPipeInstances[pipeUri] as TransportListener; if (t != null) { if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.TransportListenerStop, SR.GetString(SR.TraceCodeTransportListenerStop), t); } try { t.Stop(); } finally { namedPipeInstances.Remove(pipeUri); } } } }
protected void Close() { if (Interlocked.Increment(ref closed) > 1) { return; } int hresult = webhostUnregisterProtocol(protocolHandle); if (hresult != 0) { if (DiagnosticUtility.ShouldTraceError) { ListenerTraceUtility.TraceEvent(TraceEventType.Error, ListenerTraceCode.WasWebHostAPIFailed, SR.GetString(SR.TraceCodeWasWebHostAPIFailed), new StringTraceRecord("HRESULT", SR.GetString(SR.TraceCodeWasWebHostAPIFailed, "WebhostUnregisterProtocol", hresult.ToString(CultureInfo.CurrentCulture))), this, null); } } if (TD.WebhostUnregisterProtocolFailedIsEnabled()) { //TraceCodeWasWebHostAPIFailed TD.WebhostUnregisterProtocolFailed(this.EventTraceActivity, hresult.ToString(CultureInfo.CurrentCulture)); } }
internal bool OpenListenerChannelInstance(IActivatedMessageQueue queue) { byte[] queueBlob = queue.ListenerChannelContext.Dehydrate(); Debug.Print("ListenerAdapter[" + ProtocolName + "]::ListenerAdapter.OpenListenerChannelInstance(appPoolId:" + queue.App.AppPool.AppPoolId + " appKey:" + queue.ListenerChannelContext.AppKey + " queueId:" + queue.ListenerChannelContext.ListenerChannelId + ")"); int hresult = OpenListenerChannelInstance(queue.App.AppPool.AppPoolId, queue.ListenerChannelContext.ListenerChannelId, queueBlob); if (hresult != 0) { if (DiagnosticUtility.ShouldTraceError) { ListenerTraceUtility.TraceEvent(TraceEventType.Error, ListenerTraceCode.WasWebHostAPIFailed, SR.GetString(SR.TraceCodeWasWebHostAPIFailed), new StringTraceRecord("HRESULT", SR.GetString(SR.TraceCodeWasWebHostAPIFailed, "WebhostOpenListenerChannelInstance", hresult.ToString(CultureInfo.CurrentCulture))), this, null); } if (TD.OpenListenerChannelInstanceFailedIsEnabled()) { TD.OpenListenerChannelInstanceFailed(this.EventTraceActivity, hresult.ToString(CultureInfo.CurrentCulture)); } return(false); } return(true); }
internal ListenerConnectionDemuxer Go(IConnectionListener connectionListener) { if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.TransportListenerListenRequest, SR.GetString(SR.TraceCodeTransportListenerListenRequest), this); } ConnectionHandleDuplicated onDupHandle = new ConnectionHandleDuplicated(OnDupHandle); ListenerConnectionDemuxer connectionDemuxer = null; if (transportType == TransportType.Tcp) { connectionDemuxer = new ListenerConnectionDemuxer(connectionListener, transportType, ListenerConfig.NetTcp.MaxPendingAccepts, ListenerConfig.NetTcp.MaxPendingConnections, ListenerConfig.NetTcp.ReceiveTimeout, onDupHandle); } else if (transportType == TransportType.NamedPipe) { connectionDemuxer = new ListenerConnectionDemuxer(connectionListener, transportType, ListenerConfig.NetPipe.MaxPendingAccepts, ListenerConfig.NetPipe.MaxPendingConnections, ListenerConfig.NetPipe.ReceiveTimeout, onDupHandle); } if (ExecutionContext.IsFlowSuppressed()) { if (SecurityContext.IsFlowSuppressed()) { connectionDemuxer.StartDemuxing(); } else { using (SecurityContext.SuppressFlow()) { connectionDemuxer.StartDemuxing(); } } } else { using (ExecutionContext.SuppressFlow()) { if (SecurityContext.IsFlowSuppressed()) { connectionDemuxer.StartDemuxing(); } else { using (SecurityContext.SuppressFlow()) { connectionDemuxer.StartDemuxing(); } } } } if (DiagnosticUtility.ShouldTraceInformation) { ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.TransportListenerListening, SR.GetString(SR.TraceCodeTransportListenerListening), this); } return(connectionDemuxer); }