Esempio n. 1
0
        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);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        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);
            }
        }
 internal static void Stop(MessageQueue messageQueue, BaseUriWithWildcard path)
 {
     if (messageQueue.TransportType == TransportType.Tcp)
     {
         IPEndPoint endPoint = GetEndPoint(path.BaseAddress);
         TransportListener.Stop(endPoint);
         tcpMessageQueues.UnregisterUri(path.BaseAddress, path.HostNameComparisonMode);
     }
     else
     {
         TransportListener.Stop(path);
         namedPipeMessageQueues.UnregisterUri(path.BaseAddress, path.HostNameComparisonMode);
     }
 }
Esempio n. 4
0
 internal static void Listen(BaseUriWithWildcard pipeUri)
 {
     lock (namedPipeInstances)
     {
         if (namedPipeInstances.ContainsKey(pipeUri))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(SR.GetString(SR.PipeAddressAlreadyUsed)));
         }
         else
         {
             TransportListener t = new TransportListener(pipeUri);
             namedPipeInstances.Add(pipeUri, t);
         }
     }
 }
Esempio n. 5
0
 internal static void Listen(IPEndPoint endPoint)
 {
     lock (tcpInstances)
     {
         TransportListener t = tcpInstances[endPoint] as TransportListener;
         if (t != null)
         {
             // We use the shared TransportListener that is created earlier.
             t.AddRef();
         }
         else
         {
             t = new TransportListener(endPoint);
             tcpInstances.Add(endPoint, t);
             t.AddRef();
         }
     }
 }
Esempio n. 6
0
 protected void DropPendingMessages(bool sendFault)
 {
     lock (SessionLock)
     {
         foreach (ListenerSessionConnection sessionMessage in sessionMessages.ToArray())
         {
             if (sessionMessage != null)
             {
                 if (sendFault)
                 {
                     TransportListener.SendFault(sessionMessage.Connection, FramingEncodingString.EndpointUnavailableFault);
                 }
                 else
                 {
                     sessionMessage.Connection.Abort();
                 }
             }
         }
         sessionMessages.Clear();
     }
 }
        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);
        }
Esempio n. 8
0
        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);
                    }
                }
            }
        }
Esempio n. 9
0
        internal void EnqueueSessionAndDispatch(ListenerSessionConnection session)
        {
            lock (SessionLock)
            {
                if (!CanDispatch)
                {
                    TransportListener.SendFault(session.Connection, FramingEncodingString.EndpointUnavailableFault);
                    OnDispatchFailure(transportType);
                    return;
                }
                else if (sessionMessages.Count >= maxQueueSize)
                {
                    // Abort the connection when the queue is full.
                    if (TD.PendingSessionQueueFullIsEnabled())
                    {
                        TD.PendingSessionQueueFull(session.EventTraceActivity,
                                                   (session.Via != null) ? session.Via.ToString() : string.Empty,
                                                   sessionMessages.Count);
                    }
                    session.Connection.Abort();
                    OnDispatchFailure(transportType);
                    return;
                }
                else
                {
                    sessionMessages.Enqueue(session);
                    if (TD.PendingSessionQueueRatioIsEnabled())
                    {
                        TD.PendingSessionQueueRatio(sessionMessages.Count, maxQueueSize);
                    }
                }
            }

            OnSessionEnqueued();
            DispatchSession();
        }
Esempio n. 10
0
 bool OnConnectionDispatchFailed(IConnection connection)
 {
     TransportListener.SendFault(connection, FramingEncodingString.ConnectionDispatchFailedFault);
     return(false);
 }
 internal static void Listen(BaseUriWithWildcard pipeUri)
 {
     lock (namedPipeInstances)
     {
         if (namedPipeInstances.ContainsKey(pipeUri))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(SR.GetString(SR.PipeAddressAlreadyUsed)));
         }
         else
         {
             TransportListener t = new TransportListener(pipeUri);
             namedPipeInstances.Add(pipeUri, t);
         }
     }
 }
 internal static void Listen(IPEndPoint endPoint)
 {
     lock (tcpInstances)
     {
         TransportListener t = tcpInstances[endPoint] as TransportListener;
         if (t != null)
         {
             // We use the shared TransportListener that is created earlier. 
             t.AddRef();
         }
         else
         {
             t = new TransportListener(endPoint);
             tcpInstances.Add(endPoint, t);
             t.AddRef();
         }
     }
 }