async Task <bool> AcceptAndAcquireThrottleAsync() { var result = await acceptor.TryAcceptAsync(closingTokenSource.Token); if (result.Success) { var binder = result.Result; if (binder != null) { channel = new ListenerChannel(binder); } else { AcceptedNull(); channel = null; } } else { channel = null; } if (channel != null) { Fx.Assert(idleManager == null, "There cannot be an existing idle manager"); //idleManager = SessionIdleManager.CreateIfNeeded(channel.Binder, channelDispatcher.DefaultCommunicationTimeouts.ReceiveTimeout); } else { DoneAccepting(); return(true); } return(AcquireThrottle()); }
void Dispatch() { ListenerChannel channel = this.channel; SessionIdleManager idleManager = this.idleManager; this.channel = null; this.idleManager = null; try { if (channel != null) { ChannelHandler handler = new ChannelHandler(listenerBinder.MessageVersion, channel.Binder, /*this.throttle,*/ this, /*(channel.Throttle != null),*/ /*this.wrappedTransaction,*/ idleManager); if (!channel.Binder.HasSession) { //channelDispatcher.Channels.Add(channel.Binder.Channel); } if (channel.Binder is DuplexChannelBinder) { DuplexChannelBinder duplexChannelBinder = channel.Binder as DuplexChannelBinder; duplexChannelBinder.ChannelHandler = handler; duplexChannelBinder.DefaultCloseTimeout = DefaultCloseTimeout; if (timeouts == null) { duplexChannelBinder.DefaultSendTimeout = ServiceDefaults.SendTimeout; } else { duplexChannelBinder.DefaultSendTimeout = timeouts.SendTimeout; } } ChannelHandler.Register(handler); channel = null; idleManager = null; } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } HandleError(e); } finally { if (channel != null) { channel.Binder.Channel.Abort(); //if (this.throttle != null && this.channelDispatcher.Session) //{ // this.throttle.DeactivateChannel(); //} if (idleManager != null) { idleManager.CancelTimer(); } } } }