void SyncTransactedChannelPump() { IChannelListener listener = this.listenerBinder.Listener; for (;;) { if (this.acceptedNull || (listener.State == CommunicationState.Faulted)) { this.DoneAccepting(); break; } this.acceptor.WaitForChannel(); Transaction tx; if (this.TransactedAccept(out tx)) { if (null != tx) { this.wrappedTransaction = new WrappedTransaction(tx); if (!this.AcquireThrottle()) { break; } this.Dispatch(); } } } }
private void TransactedChannelPump() { IChannelListener listener = this.listenerBinder.Listener; Label_000C: if (this.acceptedNull || (listener.State == CommunicationState.Faulted)) { this.DoneAccepting(); } else { Transaction transaction; this.acceptor.WaitForChannel(); if (!this.TransactedAccept(out transaction) || (null == transaction)) { goto Label_000C; } this.wrappedTransaction = new WrappedTransaction(transaction); if (this.AcquireThrottle()) { this.Dispatch(); goto Label_000C; } } }
bool AcceptChannel(IChannelListener listener) { Transaction tx; if (this.TransactedAccept(out tx)) { if (null != tx) { this.wrappedTransaction = new WrappedTransaction(tx); if (!this.AcquireThrottle()) { return(false); } this.Dispatch(); } } return(true); }
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; } }
Transaction CreateOrGetAttachedTransaction() { if (null != this.acceptTransaction) { lock (ThisLock) { if (null != this.acceptTransaction) { Transaction tx = this.acceptTransaction.Transaction; this.acceptTransaction = null; return tx; } } } if (null != this.InstanceContext && this.InstanceContext.HasTransaction) { return InstanceContext.Transaction.Attached; } else { return TransactionBehavior.CreateTransaction( this.listener.ChannelDispatcher.TransactionIsolationLevel, TransactionBehavior.NormalizeTimeout(this.listener.ChannelDispatcher.TransactionTimeout)); } }
private void TransactedChannelPump() { IChannelListener listener = this.listenerBinder.Listener; Label_000C: if (this.acceptedNull || (listener.State == CommunicationState.Faulted)) { this.DoneAccepting(); } else { Transaction transaction; this.acceptor.WaitForChannel(); if (!this.TransactedAccept(out transaction) || (null == transaction)) { goto Label_000C; } this.wrappedTransaction = new WrappedTransaction(transaction); if (this.AcquireThrottle()) { this.Dispatch(); goto Label_000C; } } }
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; } }
bool AcceptChannel(IChannelListener listener) { Transaction tx; if (this.TransactedAccept(out tx)) { if (null != tx) { this.wrappedTransaction = new WrappedTransaction(tx); if (!this.AcquireThrottle()) { return false; } this.Dispatch(); } } return true; }
void SyncTransactedChannelPump() { IChannelListener listener = this.listenerBinder.Listener; for (;;) { if (this.acceptedNull || (listener.State == CommunicationState.Faulted)) { this.DoneAccepting(); break; } this.acceptor.WaitForChannel(); Transaction tx; if (this.TransactedAccept(out tx)) { if (null != tx) { this.wrappedTransaction = new WrappedTransaction(tx); if (!this.AcquireThrottle()) break; this.Dispatch(); } } } }