Пример #1
0
        public async Task <IServiceChannelDispatcher> CreateServiceChannelDispatcherAsync(IChannel channel)
        {
            var            sessionIdleManager = channel.GetProperty <ServiceChannel.SessionIdleManager>();
            IChannelBinder binder             = null;

            if (channel is IReplyChannel)
            {
                var rcbinder = channel.GetProperty <ReplyChannelBinder>();
                rcbinder.Init(channel as IReplyChannel, BaseAddress);
                binder = rcbinder;
            }
            else if (channel is IDuplexSessionChannel)
            {
                var dcbinder = channel.GetProperty <DuplexChannelBinder>();
                dcbinder.Init(channel as IDuplexSessionChannel, _requestReplyCorrelator, BaseAddress);
                binder = dcbinder;
            }
            else if (channel is IInputChannel)
            {
                var icbinder = channel.GetProperty <InputChannelBinder>();
                icbinder.Init(channel as IInputChannel, BaseAddress);
                binder = icbinder;
            }

            // TODO: Wire up wasChannelThrottled
            var channelHandler = new ChannelHandler(Binding.MessageVersion, binder, channel.GetProperty <ServiceThrottle>(),
                                                    this, /*wasChannelThrottled*/ false, sessionIdleManager);

            var channelDispatcher = channelHandler.GetDispatcher();

            channel.ChannelDispatcher = channelDispatcher;
            await channelHandler.OpenAsync();

            return(channelDispatcher);
        }
Пример #2
0
 private async Task PrivateAcquireInstanceContextAsync(ChannelHandler channel)
 {
     if ((_instanceContexts != null) && (channel.InstanceContext == null))
     {
         channel.InstanceContextServiceThrottle = this;
         await _instanceContexts.AcquireAsync();
     }
 }
Пример #3
0
 public RequestInfo(ChannelHandler channelHandler)
 {
     Endpoint = null;
     ExistingInstanceContext = null;
     Channel            = null;
     EndpointLookupDone = false;
     DispatchRuntime    = null;
     RequestContext     = null;
     ChannelHandler     = channelHandler;
 }
Пример #4
0
        internal async Task AcquireInstanceContextAndDynamicAsync(ChannelHandler channel, bool acquireInstanceContextThrottle)
        {
            // TODO: Lock removed. This code looks like it should be safe to execute without the lock. Need to verify.
            if (acquireInstanceContextThrottle)
            {
                await PrivateAcquireInstanceContextAsync(channel);
            }

            await PrivateAcquireDynamicAsync();
        }
Пример #5
0
 public void EnsurePumping()
 {
     lock (ThisLock)
     {
         if (!syncPumpEnabled)
         {
             if (!ChannelHandler.HasRegisterBeenCalled)
             {
                 ChannelHandler.Register(ChannelHandler);
             }
         }
     }
 }
Пример #6
0
        internal MessageRpc(RequestContext requestContext, Message request, DispatchOperationRuntime operation,
                            ServiceChannel channel, ServiceHostBase host, ChannelHandler channelHandler, bool cleanThread,
                            OperationContext operationContext, InstanceContext instanceContext /*, EventTraceActivity eventTraceActivity*/)
        {
            Fx.Assert((operationContext != null), "correwcf.Dispatcher.MessageRpc.MessageRpc(), operationContext == null");
            // TODO: ChannelHandler supplied an ErrorHandler, need to supply this some other way.
            //Fx.Assert(channelHandler != null, "System.ServiceModel.Dispatcher.MessageRpc.MessageRpc(), channelHandler == null");

            //this.Activity = null;
            //this.EventTraceActivity = eventTraceActivity;
            AsyncResult               = null;
            TaskResult                = null;
            CanSendReply              = true;
            Channel                   = channel;
            this.channelHandler       = channelHandler;
            Correlation               = EmptyArray.Allocate(operation.Parent.CorrelationCount);
            DidDeserializeRequestBody = false;
            Error              = null;
            ErrorProcessor     = null;
            FaultInfo          = new ErrorHandlerFaultInfo(request.Version.Addressing.DefaultFaultAction);
            HasSecurityContext = false;
            Host                            = host;
            Instance                        = null;
            AsyncProcessor                  = null;
            NotUnderstoodHeaders            = null;
            Operation                       = operation;
            OperationContext                = operationContext;
            paused                          = false;
            ParametersDisposed              = false;
            Request                         = request;
            RequestContext                  = requestContext;
            RequestContextThrewOnReply      = false;
            SuccessfullySendReply           = false;
            RequestVersion                  = request.Version;
            Reply                           = null;
            ReplyTimeoutHelper              = new TimeoutHelper();
            SecurityContext                 = null;
            InstanceContext                 = instanceContext;
            SuccessfullyBoundInstance       = false;
            SuccessfullyIncrementedActivity = false;
            SuccessfullyLockedInstance      = false;
            switchedThreads                 = !cleanThread;
            //this.transaction = null;
            InputParameters            = null;
            OutputParameters           = null;
            ReturnParameter            = null;
            isInstanceContextSingleton = InstanceContextProviderBase.IsProviderSingleton(Channel.DispatchRuntime.InstanceContextProvider);
            invokeContinueGate         = null;

            if (!operation.IsOneWay && !operation.Parent.ManualAddressing)
            {
                RequestID   = request.Headers.MessageId;
                ReplyToInfo = new RequestReplyCorrelator.ReplyToInfo(request);
            }
            else
            {
                RequestID   = null;
                ReplyToInfo = new RequestReplyCorrelator.ReplyToInfo();
            }

            //if (DiagnosticUtility.ShouldUseActivity)
            //{
            //    this.Activity = TraceUtility.ExtractActivity(this.Request);
            //}

            //if (DiagnosticUtility.ShouldUseActivity || TraceUtility.ShouldPropagateActivity)
            //{
            //    this.ResponseActivityId = ActivityIdHeader.ExtractActivityId(this.Request);
            //}
            //else
            //{
            ResponseActivityId = Guid.Empty;
            //}

            //if (this.EventTraceActivity == null && FxTrace.Trace.IsEnd2EndActivityTracingEnabled)
            //{
            //    if (this.Request != null)
            //    {
            //        this.EventTraceActivity = EventTraceActivityHelper.TryExtractActivity(this.Request, true);
            //    }
            //}
        }
Пример #7
0
        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();
                    }
                }
            }
        }