internal bool AcquireSession(ListenerHandler listener) { lock (this.ThisLock) { return(this.PrivateAcquireSessionListenerHandler(listener)); } }
internal override void CloseInput(TimeSpan timeout) { this.CloseInput(); if (this.performDefaultCloseInput) { TimeoutHelper helper = new TimeoutHelper(timeout); lock (base.ThisLock) { if (DiagnosticUtility.ShouldTraceInformation) { for (int i = 0; i < this.endpointDispatchers.Count; i++) { EndpointDispatcher endpoint = this.endpointDispatchers[i]; this.TraceEndpointLifetime(endpoint, 0x40007, System.ServiceModel.SR.GetString("TraceCodeEndpointListenerClose")); } } ListenerHandler listenerHandler = this.listenerHandler; if (listenerHandler != null) { listenerHandler.CloseInput(helper.RemainingTime()); } } if (!this.session) { ListenerHandler handler2 = this.listenerHandler; if (handler2 != null) { handler2.Close(helper.RemainingTime()); } } } }
protected override void OnOpened() { this.ThrowIfNotAttachedToHost(); base.OnOpened(); this.errorBehavior = new ErrorBehavior(this); this.filterTable = new System.ServiceModel.Dispatcher.EndpointDispatcherTable(base.ThisLock); for (int i = 0; i < this.endpointDispatchers.Count; i++) { EndpointDispatcher endpoint = this.endpointDispatchers[i]; endpoint.DispatchRuntime.GetRuntime(); endpoint.DispatchRuntime.LockDownProperties(); this.filterTable.AddEndpoint(endpoint); if ((this.addressTable != null) && (endpoint.OriginalAddress != null)) { this.addressTable.Add(endpoint.AddressFilter, endpoint.OriginalAddress, endpoint.FilterPriority); } if (DiagnosticUtility.ShouldTraceInformation) { this.TraceEndpointLifetime(endpoint, 0x40008, System.ServiceModel.SR.GetString("TraceCodeEndpointListenerOpen")); } } System.ServiceModel.Dispatcher.ServiceThrottle serviceThrottle = this.serviceThrottle; if (serviceThrottle == null) { serviceThrottle = this.host.ServiceThrottle; } IListenerBinder listenerBinder = ListenerBinder.GetBinder(this.listener, this.messageVersion); this.listenerHandler = new ListenerHandler(listenerBinder, this, this.host, serviceThrottle, this.timeouts); this.listenerHandler.Open(); }
internal override void CloseInput(TimeSpan timeout) { // we have to perform some slightly convoluted logic here due to // backwards compat. We probably need an IAsyncChannelDispatcher // interface that has timeouts and async this.CloseInput(); if (_performDefaultCloseInput) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); lock (this.ThisLock) { ListenerHandler handler = _listenerHandler; if (handler != null) { handler.CloseInput(timeoutHelper.RemainingTime()); } } if (!_session) { ListenerHandler handler = _listenerHandler; if (handler != null) { handler.Close(timeoutHelper.RemainingTime()); } } } }
internal bool AcquireSession(ListenerHandler listener) { lock (this.ThisLock) { return this.PrivateAcquireSessionListenerHandler(listener); } }
protected override void OnOpened() { base.OnOpened(); if (WcfEventSource.Instance.ListenerOpenStopIsEnabled()) { WcfEventSource.Instance.ListenerOpenStop(_eventTraceActivity); _eventTraceActivity = null; // clear this since we don't need this anymore. } _errorBehavior = new ErrorBehavior(this); _filterTable = new EndpointDispatcherTable(this.ThisLock); for (int i = 0; i < _endpointDispatchers.Count; i++) { EndpointDispatcher endpoint = _endpointDispatchers[i]; // Force a build of the runtime to catch any unexpected errors before we are done opening. // Lock down the DispatchRuntime. endpoint.DispatchRuntime.LockDownProperties(); _filterTable.AddEndpoint(endpoint); } IListenerBinder binder = ListenerBinder.GetBinder(_listener, _messageVersion); _listenerHandler = new ListenerHandler(binder, this, _timeouts); _listenerHandler.Open(); // This never throws, which is why it's ok for it to happen in OnOpened }
private bool PrivateAcquireSessionListenerHandler(ListenerHandler listener) { if (((this.sessions != null) && (listener.Channel != null)) && (listener.Channel.Throttle == null)) { listener.Channel.Throttle = this; return(this.sessions.Acquire(listener)); } return(true); }
private static void AcceptCallback(IAsyncResult result) { if (!result.CompletedSynchronously) { ListenerHandler asyncState = (ListenerHandler)result.AsyncState; if (asyncState.HandleEndAccept(result)) { asyncState.Dispatch(); asyncState.ChannelPump(); } } }
private static void InitiateChannelPump(object state) { ListenerHandler handler = state as ListenerHandler; if (handler.ChannelDispatcher.IsTransactedAccept) { handler.TransactedChannelPump(); } else { handler.ChannelPump(); } }
private static void WaitCallback(IAsyncResult result) { if (result.CompletedSynchronously) { return; } ; ListenerHandler listenerHandler = (ListenerHandler)result.AsyncState; IChannelListener listener = listenerHandler._listenerBinder.Listener; listenerHandler.Dispatch(); }
protected override void OnAbort() { if (this.listener != null) { this.listener.Abort(); } ListenerHandler listenerHandler = this.listenerHandler; if (listenerHandler != null) { listenerHandler.Abort(); } this.AbortPendingChannels(); }
static void AcceptCallback(IAsyncResult result) { if (result.CompletedSynchronously) { return; } ListenerHandler thisPtr = (ListenerHandler)result.AsyncState; if (thisPtr.HandleEndAccept(result)) { thisPtr.Dispatch(); thisPtr.ChannelPump(); } }
protected override void OnOpened() { ThrowIfNotAttachedToHost(); base.OnOpened(); if (TD.ListenerOpenStopIsEnabled()) { TD.ListenerOpenStop(this.eventTraceActivity); this.eventTraceActivity = null; // clear this since we don't need this anymore. } this.errorBehavior = new ErrorBehavior(this); this.filterTable = new EndpointDispatcherTable(this.ThisLock); for (int i = 0; i < this.endpointDispatchers.Count; i++) { EndpointDispatcher endpoint = this.endpointDispatchers[i]; // Force a build of the runtime to catch any unexpected errors before we are done opening. endpoint.DispatchRuntime.GetRuntime(); // Lock down the DispatchRuntime. endpoint.DispatchRuntime.LockDownProperties(); this.filterTable.AddEndpoint(endpoint); if ((this.addressTable != null) && (endpoint.OriginalAddress != null)) { this.addressTable.Add(endpoint.AddressFilter, endpoint.OriginalAddress, endpoint.FilterPriority); } if (DiagnosticUtility.ShouldTraceInformation) { this.TraceEndpointLifetime(endpoint, TraceCode.EndpointListenerOpen, SR.GetString(SR.TraceCodeEndpointListenerOpen)); } } ServiceThrottle throttle = this.serviceThrottle; if (throttle == null) { throttle = this.host.ServiceThrottle; } IListenerBinder binder = ListenerBinder.GetBinder(this.listener, this.messageVersion); this.listenerHandler = new ListenerHandler(binder, this, this.host, throttle, this.timeouts); this.listenerHandler.Open(); // This never throws, which is why it's ok for it to happen in OnOpened }
protected override void OnClose(TimeSpan timeout) { TimeoutHelper helper = new TimeoutHelper(timeout); if (this.listener != null) { this.listener.Close(helper.RemainingTime()); } ListenerHandler listenerHandler = this.listenerHandler; if (listenerHandler != null) { listenerHandler.Close(helper.RemainingTime()); } this.AbortPendingChannels(); }
protected override void OnAbort() { if (_listener != null) { _listener.Abort(); } ListenerHandler handler = _listenerHandler; if (handler != null) { handler.Abort(); } this.AbortPendingChannels(); }
protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state) { List <ICommunicationObject> collection = new List <ICommunicationObject>(); if (this.listener != null) { collection.Add(this.listener); } ListenerHandler listenerHandler = this.listenerHandler; if (listenerHandler != null) { collection.Add(listenerHandler); } return(new CloseCollectionAsyncResult(timeout, callback, state, collection)); }
static void WaitCallback(IAsyncResult result) { if (result.CompletedSynchronously) { return; } ; ListenerHandler listenerHandler = (ListenerHandler)result.AsyncState; IChannelListener listener = listenerHandler.listenerBinder.Listener; listenerHandler.acceptor.EndWaitForChannel(result); if (listenerHandler.AcceptChannel(listener)) { listenerHandler.AsyncTransactedChannelPump(); } }
protected override void OnClose(TimeSpan timeout) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); if (_listener != null) { _listener.Close(timeoutHelper.RemainingTime()); } ListenerHandler handler = _listenerHandler; if (handler != null) { handler.Close(timeoutHelper.RemainingTime()); } AbortPendingChannels(); }
internal ChannelHandler(ChannelHandler handler, TransactedBatchContext context) { this.messageVersion = handler.messageVersion; this.isManualAddressing = handler.isManualAddressing; this.binder = handler.binder; this.listener = handler.listener; this.wasChannelThrottled = handler.wasChannelThrottled; this.host = handler.host; this.receiveSynchronously = true; this.receiveWithTransaction = true; this.duplexBinder = handler.duplexBinder; this.hasSession = handler.hasSession; this.isConcurrent = handler.isConcurrent; this.receiver = handler.receiver; this.sharedTransactedBatchContext = context.Shared; this.transactedBatchContext = context; this.requestInfo = new RequestInfo(this); }
protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state) { List <ICommunicationObject> list = new List <ICommunicationObject>(); if (_listener != null) { list.Add(_listener); } ListenerHandler handler = _listenerHandler; if (handler != null) { list.Add(handler); } return(new CloseCollectionAsyncResult(timeout, callback, state, list)); }
static void InitiateChannelPump(object state) { ListenerHandler listenerHandler = state as ListenerHandler; if (listenerHandler.ChannelDispatcher.IsTransactedAccept) { if (listenerHandler.ChannelDispatcher.AsynchronousTransactedAcceptEnabled) { listenerHandler.AsyncTransactedChannelPump(); } else { listenerHandler.SyncTransactedChannelPump(); } } else { listenerHandler.ChannelPump(); } }
internal ChannelHandler(MessageVersion messageVersion, IChannelBinder binder, ListenerHandler listener, SessionIdleManager idleManager) { ChannelDispatcher channelDispatcher = listener.ChannelDispatcher; _messageVersion = messageVersion; _isManualAddressing = channelDispatcher.ManualAddressing; _binder = binder; _listener = listener; _receiveSynchronously = channelDispatcher.ReceiveSynchronously; _sendAsynchronously = channelDispatcher.SendAsynchronously; _duplexBinder = binder as DuplexChannelBinder; _hasSession = binder.HasSession; _isConcurrent = ConcurrencyBehavior.IsConcurrent(channelDispatcher, _hasSession); if (channelDispatcher.MaxPendingReceives > 1) { throw NotImplemented.ByDesign; } if (channelDispatcher.BufferedReceiveEnabled) { _binder = new BufferedReceiveBinder(_binder); } _receiver = new ErrorHandlingReceiver(_binder, channelDispatcher); _idleManager = idleManager; Fx.Assert((_idleManager != null) == (_binder.HasSession && _listener.ChannelDispatcher.DefaultCommunicationTimeouts.ReceiveTimeout != TimeSpan.MaxValue), "idle manager is present only when there is a session with a finite receive timeout"); _requestInfo = new RequestInfo(this); if (_listener.State == CommunicationState.Opened) { _listener.ChannelDispatcher.Channels.IncrementActivityCount(); _incrementedActivityCountInConstructor = true; } }
internal override void CloseInput(TimeSpan timeout) { // we have to perform some slightly convoluted logic here due to // backwards compat. We probably need an IAsyncChannelDispatcher // interface that has timeouts and async this.CloseInput(); if (this.performDefaultCloseInput) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); lock (this.ThisLock) { if (DiagnosticUtility.ShouldTraceInformation) { for (int i = 0; i < this.endpointDispatchers.Count; i++) { EndpointDispatcher endpointDispatcher = this.endpointDispatchers[i]; this.TraceEndpointLifetime(endpointDispatcher, TraceCode.EndpointListenerClose, SR.GetString(SR.TraceCodeEndpointListenerClose)); } } ListenerHandler handler = this.listenerHandler; if (handler != null) { handler.CloseInput(timeoutHelper.RemainingTime()); } } if (!this.session) { ListenerHandler handler = this.listenerHandler; if (handler != null) { handler.Close(timeoutHelper.RemainingTime()); } } } }
internal CloseChannelState(ListenerHandler listenerHandler, IChannel channel) { this.listenerHandler = listenerHandler; this.channel = channel; }
bool PrivateAcquireSessionListenerHandler(ListenerHandler listener) { if ((this.sessions != null) && (listener.Channel != null) && (listener.Channel.Throttle == null)) { listener.Channel.Throttle = this; return this.sessions.Acquire(listener); } else { return true; } }
internal CloseChannelState(ListenerHandler listenerHandler, IChannel channel) { _listenerHandler = listenerHandler; _channel = channel; }
internal ChannelHandler(MessageVersion messageVersion, IChannelBinder binder, ServiceThrottle throttle, ListenerHandler listener, bool wasChannelThrottled, WrappedTransaction acceptTransaction, SessionIdleManager idleManager) { ChannelDispatcher channelDispatcher = listener.ChannelDispatcher; this.messageVersion = messageVersion; this.isManualAddressing = channelDispatcher.ManualAddressing; this.binder = binder; this.throttle = throttle; this.listener = listener; this.wasChannelThrottled = wasChannelThrottled; this.host = listener.Host; this.receiveSynchronously = channelDispatcher.ReceiveSynchronously; this.sendAsynchronously = channelDispatcher.SendAsynchronously; this.duplexBinder = binder as DuplexChannelBinder; this.hasSession = binder.HasSession; this.isConcurrent = ConcurrencyBehavior.IsConcurrent(channelDispatcher, this.hasSession); if (channelDispatcher.MaxPendingReceives > 1) { // We need to preserve order if the ChannelHandler is not concurrent. this.binder = new MultipleReceiveBinder( this.binder, channelDispatcher.MaxPendingReceives, !this.isConcurrent); } if (channelDispatcher.BufferedReceiveEnabled) { this.binder = new BufferedReceiveBinder(this.binder); } this.receiver = new ErrorHandlingReceiver(this.binder, channelDispatcher); this.idleManager = idleManager; Fx.Assert((this.idleManager != null) == (this.binder.HasSession && this.listener.ChannelDispatcher.DefaultCommunicationTimeouts.ReceiveTimeout != TimeSpan.MaxValue), "idle manager is present only when there is a session with a finite receive timeout"); if (channelDispatcher.IsTransactedReceive && !channelDispatcher.ReceiveContextEnabled) { receiveSynchronously = true; receiveWithTransaction = true; if (channelDispatcher.MaxTransactedBatchSize > 0) { int maxConcurrentBatches = 1; if (null != throttle && throttle.MaxConcurrentCalls > 1) { maxConcurrentBatches = throttle.MaxConcurrentCalls; foreach (EndpointDispatcher endpointDispatcher in channelDispatcher.Endpoints) { if (ConcurrencyMode.Multiple != endpointDispatcher.DispatchRuntime.ConcurrencyMode) { maxConcurrentBatches = 1; break; } } } this.sharedTransactedBatchContext = new SharedTransactedBatchContext(this, channelDispatcher, maxConcurrentBatches); this.isMainTransactedBatchHandler = true; this.throttle = null; } } else if (channelDispatcher.IsTransactedReceive && channelDispatcher.ReceiveContextEnabled && channelDispatcher.MaxTransactedBatchSize > 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.IncompatibleBehaviors))); } if (this.binder.HasSession) { this.sessionOpenNotification = this.binder.Channel.GetProperty<SessionOpenNotification>(); this.needToCreateSessionOpenNotificationMessage = this.sessionOpenNotification != null && this.sessionOpenNotification.IsEnabled; } this.acceptTransaction = acceptTransaction; this.requestInfo = new RequestInfo(this); if (this.listener.State == CommunicationState.Opened) { this.listener.ChannelDispatcher.Channels.IncrementActivityCount(); this.incrementedActivityCountInConstructor = true; } }
internal ChannelHandler(ChannelHandler handler, TransactedBatchContext context) { this.messageVersion = handler.messageVersion; this.isManualAddressing = handler.isManualAddressing; this.binder = handler.binder; this.listener = handler.listener; this.wasChannelThrottled = handler.wasChannelThrottled; this.host = handler.host; this.receiveSynchronously = true; this.receiveWithTransaction = true; this.duplexBinder = handler.duplexBinder; this.hasSession = handler.hasSession; this.isConcurrent = handler.isConcurrent; this.receiver = handler.receiver; this.sharedTransactedBatchContext = context.Shared; this.transactedBatchContext = context; this.requestInfo = new RequestInfo(this); this.sendAsynchronously = handler.sendAsynchronously; this.sessionOpenNotification = handler.sessionOpenNotification; this.needToCreateSessionOpenNotificationMessage = handler.needToCreateSessionOpenNotificationMessage; this.shouldRejectMessageWithOnOpenActionHeader = handler.shouldRejectMessageWithOnOpenActionHeader; }
internal ChannelHandler(MessageVersion messageVersion, IChannelBinder binder, ServiceThrottle throttle, ListenerHandler listener, bool wasChannelThrottled, WrappedTransaction acceptTransaction, ServiceChannel.SessionIdleManager idleManager) { ChannelDispatcher channelDispatcher = listener.ChannelDispatcher; this.messageVersion = messageVersion; this.isManualAddressing = channelDispatcher.ManualAddressing; this.binder = binder; this.throttle = throttle; this.listener = listener; this.wasChannelThrottled = wasChannelThrottled; this.host = listener.Host; this.receiveSynchronously = channelDispatcher.ReceiveSynchronously; this.duplexBinder = binder as DuplexChannelBinder; this.hasSession = binder.HasSession; this.isConcurrent = ConcurrencyBehavior.IsConcurrent(channelDispatcher, this.hasSession); if (channelDispatcher.MaxPendingReceives > 1) { this.binder = new MultipleReceiveBinder(this.binder, channelDispatcher.MaxPendingReceives, !this.isConcurrent); } if (channelDispatcher.BufferedReceiveEnabled) { this.binder = new BufferedReceiveBinder(this.binder); } this.receiver = new ErrorHandlingReceiver(this.binder, channelDispatcher); this.idleManager = idleManager; if (!channelDispatcher.IsTransactedReceive || channelDispatcher.ReceiveContextEnabled) { if ((channelDispatcher.IsTransactedReceive && channelDispatcher.ReceiveContextEnabled) && (channelDispatcher.MaxTransactedBatchSize > 0)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("IncompatibleBehaviors"))); } } else { this.receiveSynchronously = true; this.receiveWithTransaction = true; if (channelDispatcher.MaxTransactedBatchSize > 0) { int maxConcurrentBatches = 1; if ((throttle != null) && (throttle.MaxConcurrentCalls > 1)) { maxConcurrentBatches = throttle.MaxConcurrentCalls; foreach (EndpointDispatcher dispatcher2 in channelDispatcher.Endpoints) { if (ConcurrencyMode.Multiple != dispatcher2.DispatchRuntime.ConcurrencyMode) { maxConcurrentBatches = 1; break; } } } this.sharedTransactedBatchContext = new SharedTransactedBatchContext(this, channelDispatcher, maxConcurrentBatches); this.isMainTransactedBatchHandler = true; this.throttle = null; } } this.acceptTransaction = acceptTransaction; this.requestInfo = new RequestInfo(this); if (!this.hasSession && (this.listener.State == CommunicationState.Opened)) { this.listener.ChannelDispatcher.Channels.IncrementActivityCount(); this.incrementedActivityCountInConstructor = true; } }
private static void InitiateChannelPump(object state) { ListenerHandler listenerHandler = state as ListenerHandler; listenerHandler.ChannelPump(); }