コード例 #1
0
ファイル: ServiceThrottle.cs プロジェクト: dox0/DotNet471RS3
 internal bool AcquireCall(ChannelHandler channel)
 {
     lock (this.ThisLock)
     {
         return(this.PrivateAcquireCall(channel));
     }
 }
コード例 #2
0
        //Called from RPC.DisposeRequestContext for sucessful invoke.
        //Mode is RCBA.ManualAcknowledgement = false.
        public IAsyncResult BeginComplete(TimeSpan timeout, Transaction transaction, ChannelHandler channelHandler, AsyncCallback callback, object state)
        {
            IAsyncResult result = null;

            if (transaction != null)
            {
                using (TransactionScope scope = new TransactionScope(transaction))
                {
                    TransactionOutcomeListener.EnsureReceiveContextAbandonOnTransactionRollback(this.receiveContext, transaction, channelHandler);
                    result = this.receiveContext.BeginComplete(
                        timeout,
                        callback,
                        state);
                    scope.Complete();
                }
            }
            else
            {
                result = this.receiveContext.BeginComplete(
                    timeout,
                    callback,
                    state);
            }
            return(result);
        }
コード例 #3
0
        private void Dispatch()
        {
            ListenerChannel    channel     = _channel;
            SessionIdleManager idleManager = _idleManager;

            _channel     = null;
            _idleManager = null;

            try
            {
                if (channel != null)
                {
                    ChannelHandler handler = new ChannelHandler(_listenerBinder.MessageVersion, channel.Binder, this, 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 = this.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;
                }
                this.HandleError(e);
            }
            finally
            {
                if (channel != null)
                {
                    channel.Binder.Channel.Abort();
                    if (idleManager != null)
                    {
                        idleManager.CancelTimer();
                    }
                }
            }
        }
コード例 #4
0
 internal void EnsureReceive()
 {
     using (ServiceModelActivity.BoundOperation(this.Activity))
     {
         ChannelHandler.Register(this.channelHandler);
     }
 }
 internal bool AcquireCall(ChannelHandler channel)
 {
     lock (this.ThisLock)
     {
         return this.PrivateAcquireCall(channel);
     }
 }
コード例 #6
0
            public AcknowledgementCompleteAsyncResult(
                ReceiveContext receiveContext,
                TimeSpan timeout,
                ref MessageRpc rpc,
                Transaction transaction,
                AsyncCallback callback,
                object state) : base(callback, state)
            {
                this.receiveContext     = receiveContext;
                this.currentTransaction = transaction;
                this.channelHandler     = rpc.channelHandler;
                this.resumableRPC       = rpc.Pause();

                bool completeThrew = true;

                try
                {
                    bool completed = this.Complete(timeout);
                    completeThrew = false;

                    if (completed)
                    {
                        this.resumableRPC = null;
                        rpc.UnPause();
                        this.Complete(true);
                    }
                }
                finally
                {
                    if (completeThrew)
                    {
                        rpc.UnPause();
                    }
                }
            }
コード例 #7
0
        private void Dispatch()
        {
            ListenerChannel channel = this.channel;

            ServiceChannel.SessionIdleManager idleManager = this.idleManager;
            this.channel     = null;
            this.idleManager = null;
            try
            {
                if (channel != null)
                {
                    ChannelHandler handler = new ChannelHandler(this.listenerBinder.MessageVersion, channel.Binder, this.throttle, this, channel.Throttle != null, this.wrappedTransaction, idleManager);
                    if (!channel.Binder.HasSession)
                    {
                        this.channelDispatcher.Channels.Add(channel.Binder.Channel);
                    }
                    if (channel.Binder is DuplexChannelBinder)
                    {
                        DuplexChannelBinder binder = channel.Binder as DuplexChannelBinder;
                        binder.ChannelHandler      = handler;
                        binder.DefaultCloseTimeout = this.DefaultCloseTimeout;
                        if (this.timeouts == null)
                        {
                            binder.DefaultSendTimeout = ServiceDefaults.SendTimeout;
                        }
                        else
                        {
                            binder.DefaultSendTimeout = this.timeouts.SendTimeout;
                        }
                    }
                    ChannelHandler.Register(handler);
                    channel     = null;
                    idleManager = null;
                }
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }
                this.HandleError(exception);
            }
            finally
            {
                if (channel != null)
                {
                    channel.Binder.Channel.Abort();
                    if ((this.throttle != null) && this.channelDispatcher.Session)
                    {
                        this.throttle.DeactivateChannel();
                    }
                    if (idleManager != null)
                    {
                        idleManager.CancelTimer();
                    }
                }
            }
        }
コード例 #8
0
 private bool PrivateAcquireCall(ChannelHandler channel)
 {
     if (this.calls != null)
     {
         return(this.calls.Acquire(channel));
     }
     return(true);
 }
 public void NotifyInvokeReceived()
 {
     using (ServiceModelActivity.BoundOperation(this.activity))
     {
         ChannelHandler.Register(this.handler);
     }
     this.DidInvokerEnsurePump = true;
 }
コード例 #10
0
 public void NotifyInvokeReceived(RequestContext request)
 {
     using (ServiceModelActivity.BoundOperation(_activity))
     {
         ChannelHandler.Register(_handler, request);
     }
     this.DidInvokerEnsurePump = true;
 }
コード例 #11
0
 private bool PrivateAcquireDynamic(ChannelHandler channel)
 {
     if (this.dynamic != null)
     {
         return(this.dynamic.Acquire(channel));
     }
     return(true);
 }
コード例 #12
0
 private bool PrivateAcquireInstanceContext(ChannelHandler channel)
 {
     if ((this.instanceContexts != null) && (channel.InstanceContext == null))
     {
         channel.InstanceContextServiceThrottle = this;
         return(this.instanceContexts.Acquire(channel));
     }
     return(true);
 }
コード例 #13
0
        private void GotCall(object state)
        {
            ChannelHandler handler = (ChannelHandler)state;

            lock (this.ThisLock)
            {
                handler.ThrottleAcquiredForCall();
            }
        }
コード例 #14
0
ファイル: ServiceThrottle.cs プロジェクト: dox0/DotNet471RS3
        void GotCall(object state)
        {
            ChannelHandler channel = (ChannelHandler)state;

            lock (this.ThisLock)
            {
                channel.ThrottleAcquiredForCall();
            }
        }
コード例 #15
0
ファイル: ChannelHandler.cs プロジェクト: shenhx/dotnet-wcf
        internal static void Register(ChannelHandler handler, RequestContext request)
        {
            BufferedReceiveBinder bufferedBinder = handler.Binder as BufferedReceiveBinder;

            Fx.Assert(bufferedBinder != null, "ChannelHandler.Binder is not a BufferedReceiveBinder");

            bufferedBinder.InjectRequest(request);
            handler.Register();
        }
コード例 #16
0
ファイル: ChannelHandler.cs プロジェクト: shenhx/dotnet-wcf
 public RequestInfo(ChannelHandler channelHandler)
 {
     this.Endpoint = null;
     this.ExistingInstanceContext = null;
     this.Channel            = null;
     this.EndpointLookupDone = false;
     this.DispatchRuntime    = null;
     this.RequestContext     = null;
     this.ChannelHandler     = channelHandler;
 }
コード例 #17
0
ファイル: ChannelHandler.cs プロジェクト: shenhx/dotnet-wcf
        private static void OnStartSyncMessagePump(object state)
        {
            ChannelHandler handler = state as ChannelHandler;

            if (WcfEventSource.Instance.ChannelReceiveStopIsEnabled())
            {
                WcfEventSource.Instance.ChannelReceiveStop(handler.EventTraceActivity, state.GetHashCode());
            }
            handler.SyncMessagePump();
        }
コード例 #18
0
 public RequestInfo(ChannelHandler channelHandler)
 {
     Endpoint = null;
     ExistingInstanceContext = null;
     Channel            = null;
     EndpointLookupDone = false;
     DispatchRuntime    = null;
     RequestContext     = null;
     ChannelHandler     = channelHandler;
 }
コード例 #19
0
 internal bool AcquireInstanceContextAndDynamic(ChannelHandler channel, bool acquireInstanceContextThrottle)
 {
     lock (this.ThisLock)
     {
         if (!acquireInstanceContextThrottle)
         {
             return(this.PrivateAcquireDynamic(channel));
         }
         return(this.PrivateAcquireInstanceContext(channel) && this.PrivateAcquireDynamic(channel));
     }
 }
コード例 #20
0
 internal bool AcquireInstanceContextAndDynamic(ChannelHandler channel, bool acquireInstanceContextThrottle)
 {
     lock (this.ThisLock)
     {
         if (!acquireInstanceContextThrottle)
         {
             return this.PrivateAcquireDynamic(channel);
         }
         return (this.PrivateAcquireInstanceContext(channel) && this.PrivateAcquireDynamic(channel));
     }
 }
コード例 #21
0
ファイル: ServiceThrottle.cs プロジェクト: dox0/DotNet471RS3
        void GotInstanceContext(object state)
        {
            ChannelHandler channel = (ChannelHandler)state;

            lock (this.ThisLock)
            {
                if (this.PrivateAcquireDynamic(channel))
                {
                    channel.ThrottleAcquired();
                }
            }
        }
 internal void DispatchStarted()
 {
     lock (this.thisLock)
     {
         this.currentConcurrentDispatches++;
         if ((this.currentConcurrentDispatches == this.currentConcurrentBatches) && (this.currentConcurrentBatches < this.maxConcurrentBatches))
         {
             TransactedBatchContext context = new TransactedBatchContext(this);
             this.currentConcurrentBatches++;
             ChannelHandler handler = new ChannelHandler(this.handler, context);
             ChannelHandler.Register(handler);
         }
     }
 }
 internal SharedTransactedBatchContext(ChannelHandler handler, ChannelDispatcher dispatcher, int maxConcurrentBatches)
 {
     this.handler = handler;
     this.maxBatchSize = dispatcher.MaxTransactedBatchSize;
     this.maxConcurrentBatches = maxConcurrentBatches;
     this.currentBatchSize = dispatcher.MaxTransactedBatchSize;
     this.currentConcurrentBatches = 0;
     this.currentConcurrentDispatches = 0;
     this.successfullCommits = 0;
     this.isBatching = true;
     this.isolationLevel = dispatcher.TransactionIsolationLevel;
     this.txTimeout = TransactionBehavior.NormalizeTimeout(dispatcher.TransactionTimeout);
     this.BatchingStateChanged(this.isBatching);
 }
コード例 #24
0
 internal SharedTransactedBatchContext(ChannelHandler handler, ChannelDispatcher dispatcher, int maxConcurrentBatches)
 {
     this.handler                     = handler;
     this.maxBatchSize                = dispatcher.MaxTransactedBatchSize;
     this.maxConcurrentBatches        = maxConcurrentBatches;
     this.currentBatchSize            = dispatcher.MaxTransactedBatchSize;
     this.currentConcurrentBatches    = 0;
     this.currentConcurrentDispatches = 0;
     this.successfullCommits          = 0;
     this.isBatching                  = true;
     this.isolationLevel              = dispatcher.TransactionIsolationLevel;
     this.txTimeout                   = TransactionBehavior.NormalizeTimeout(dispatcher.TransactionTimeout);
     BatchingStateChanged(this.isBatching);
 }
コード例 #25
0
 internal void DispatchStarted()
 {
     lock (thisLock)
     {
         ++this.currentConcurrentDispatches;
         if (this.currentConcurrentDispatches == this.currentConcurrentBatches && this.currentConcurrentBatches < this.maxConcurrentBatches)
         {
             TransactedBatchContext context = new TransactedBatchContext(this);
             ++this.currentConcurrentBatches;
             ChannelHandler newHandler = new ChannelHandler(this.handler, context);
             ChannelHandler.Register(newHandler);
         }
     }
 }
コード例 #26
0
 internal void DispatchStarted()
 {
     lock (this.thisLock)
     {
         this.currentConcurrentDispatches++;
         if ((this.currentConcurrentDispatches == this.currentConcurrentBatches) && (this.currentConcurrentBatches < this.maxConcurrentBatches))
         {
             TransactedBatchContext context = new TransactedBatchContext(this);
             this.currentConcurrentBatches++;
             ChannelHandler handler = new ChannelHandler(this.handler, context);
             ChannelHandler.Register(handler);
         }
     }
 }
 public IAsyncResult BeginComplete(TimeSpan timeout, Transaction transaction, ChannelHandler channelHandler, AsyncCallback callback, object state)
 {
     IAsyncResult result = null;
     if (transaction != null)
     {
         using (TransactionScope scope = new TransactionScope(transaction))
         {
             TransactionOutcomeListener.EnsureReceiveContextAbandonOnTransactionRollback(this.receiveContext, transaction, channelHandler);
             result = this.receiveContext.BeginComplete(timeout, callback, state);
             scope.Complete();
             return result;
         }
     }
     return this.receiveContext.BeginComplete(timeout, callback, state);
 }
コード例 #28
0
 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);
 }
コード例 #29
0
ファイル: ChannelHandler.cs プロジェクト: shenhx/dotnet-wcf
        private static void OnAsyncReplyComplete(IAsyncResult result)
        {
            if (result.CompletedSynchronously)
            {
                return;
            }

            try
            {
                var state = (ContinuationState)result.AsyncState;
                ChannelHandler.AsyncReplyComplete(result, state);
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
            }
        }
コード例 #30
0
ファイル: ChannelHandler.cs プロジェクト: shenhx/dotnet-wcf
 internal static void Register(ChannelHandler handler)
 {
     handler.Register();
 }
コード例 #31
0
 internal void DispatchStarted()
 {
     lock (thisLock)
     {
         ++this.currentConcurrentDispatches;
         if (this.currentConcurrentDispatches == this.currentConcurrentBatches && this.currentConcurrentBatches < this.maxConcurrentBatches)
         {
             TransactedBatchContext context = new TransactedBatchContext(this);
             ++this.currentConcurrentBatches;
             ChannelHandler newHandler = new ChannelHandler(this.handler, context);
             ChannelHandler.Register(newHandler);
         }
     }
 }
コード例 #32
0
        internal static void Register(ChannelHandler handler, RequestContext request)
        {
            BufferedReceiveBinder bufferedBinder = handler.Binder as BufferedReceiveBinder;
            Fx.Assert(bufferedBinder != null, "ChannelHandler.Binder is not a BufferedReceiveBinder");

            bufferedBinder.InjectRequest(request);
            handler.Register();
        }
コード例 #33
0
 internal static void Register(ChannelHandler handler)
 {
     handler.Register();
 }
コード例 #34
0
 public TransactionOutcomeListener(ReceiveContext receiveContext, Transaction transaction, ChannelHandler handler)
 {
     this.receiveContext = receiveContext;
     transaction.TransactionCompleted += new TransactionCompletedEventHandler(this.OnTransactionComplete);
     this.channelHandler = handler;
 }
コード例 #35
0
ファイル: ChannelHandler.cs プロジェクト: shenhx/dotnet-wcf
        private void ProvideFaultAndReplyFailure(RequestContext request, Exception exception, ref ErrorHandlerFaultInfo faultInfo, out bool replied, out bool replySentAsync)
        {
            replied        = false;
            replySentAsync = false;
            bool requestMessageIsFault = false;

            try
            {
                requestMessageIsFault = request.RequestMessage.IsFault;
            }
#pragma warning suppress 56500 // covered by FxCOP
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                // do not propagate non-fatal exceptions
            }

            bool enableFaults = false;
            if (_listener != null)
            {
                enableFaults = _listener.ChannelDispatcher.EnableFaults;
            }
            else if (_channel != null && _channel.IsClient)
            {
                enableFaults = _channel.ClientRuntime.EnableFaults;
            }

            if ((!requestMessageIsFault) && enableFaults)
            {
                this.ProvideFault(exception, ref faultInfo);
                if (faultInfo.Fault != null)
                {
                    Message reply = faultInfo.Fault;
                    try
                    {
                        try
                        {
                            if (this.PrepareReply(request, reply))
                            {
                                if (_sendAsynchronously)
                                {
                                    var state = new ContinuationState {
                                        ChannelHandler = this, Channel = _channel, Exception = exception, FaultInfo = faultInfo, Request = request, Reply = reply
                                    };
                                    var result = request.BeginReply(reply, ChannelHandler.s_onAsyncReplyComplete, state);
                                    if (result.CompletedSynchronously)
                                    {
                                        ChannelHandler.AsyncReplyComplete(result, state);
                                        replied = true;
                                    }
                                    else
                                    {
                                        replySentAsync = true;
                                    }
                                }
                                else
                                {
                                    request.Reply(reply);
                                    replied = true;
                                }
                            }
                        }
                        finally
                        {
                            if (!replySentAsync)
                            {
                                reply.Close();
                            }
                        }
                    }
#pragma warning suppress 56500 // covered by FxCOP
                    catch (Exception e)
                    {
                        if (Fx.IsFatal(e))
                        {
                            throw;
                        }
                        this.HandleError(e);
                    }
                }
            }
        }
コード例 #36
0
 private bool PrivateAcquireDynamic(ChannelHandler channel)
 {
     if (this.dynamic != null)
     {
         return this.dynamic.Acquire(channel);
     }
     return true;
 }
コード例 #37
0
 internal MessageRpc(System.ServiceModel.Channels.RequestContext requestContext, Message request, DispatchOperationRuntime operation, ServiceChannel channel, ServiceHostBase host, ChannelHandler channelHandler, bool cleanThread, System.ServiceModel.OperationContext operationContext, System.ServiceModel.InstanceContext instanceContext)
 {
     this.Activity                   = null;
     this.AsyncResult                = null;
     this.CanSendReply               = true;
     this.Channel                    = channel;
     this.channelHandler             = channelHandler;
     this.Correlation                = EmptyArray.Allocate(operation.Parent.CorrelationCount);
     this.CorrelationCallback        = null;
     this.DidDeserializeRequestBody  = false;
     this.TransactionMessageProperty = null;
     this.TransactedBatchContext     = null;
     this.Error              = null;
     this.ErrorProcessor     = null;
     this.FaultInfo          = new ErrorHandlerFaultInfo(request.Version.Addressing.DefaultFaultAction);
     this.HasSecurityContext = false;
     this.Host     = host;
     this.Instance = null;
     this.MessageRpcOwnsInstanceContextThrottle = false;
     this.NextProcessor        = null;
     this.NotUnderstoodHeaders = null;
     this.Operation            = operation;
     this.OperationContext     = operationContext;
     this.paused                     = false;
     this.ParametersDisposed         = false;
     this.ReceiveContext             = null;
     this.Request                    = request;
     this.RequestContext             = requestContext;
     this.RequestContextThrewOnReply = false;
     this.SuccessfullySendReply      = false;
     this.RequestVersion             = request.Version;
     this.Reply = null;
     this.ReplyTimeoutHelper              = new TimeoutHelper();
     this.SecurityContext                 = null;
     this.InstanceContext                 = instanceContext;
     this.SuccessfullyBoundInstance       = false;
     this.SuccessfullyIncrementedActivity = false;
     this.SuccessfullyLockedInstance      = false;
     this.switchedThreads                 = !cleanThread;
     this.transaction                = null;
     this.InputParameters            = null;
     this.OutputParameters           = null;
     this.ReturnParameter            = null;
     this.isInstanceContextSingleton = InstanceContextProviderBase.IsProviderSingleton(this.Channel.DispatchRuntime.InstanceContextProvider);
     this.invokeContinueGate         = null;
     if (!operation.IsOneWay && !operation.Parent.ManualAddressing)
     {
         this.RequestID   = request.Headers.MessageId;
         this.ReplyToInfo = new System.ServiceModel.Channels.RequestReplyCorrelator.ReplyToInfo(request);
     }
     else
     {
         this.RequestID   = null;
         this.ReplyToInfo = new System.ServiceModel.Channels.RequestReplyCorrelator.ReplyToInfo();
     }
     this.HostingProperty = AspNetEnvironment.Current.PrepareMessageForDispatch(request);
     if (DiagnosticUtility.ShouldUseActivity)
     {
         this.Activity = TraceUtility.ExtractActivity(this.Request);
     }
     if (DiagnosticUtility.ShouldUseActivity || TraceUtility.ShouldPropagateActivity)
     {
         this.ResponseActivityId = ActivityIdHeader.ExtractActivityId(this.Request);
     }
     else
     {
         this.ResponseActivityId = Guid.Empty;
     }
     this.InvokeNotification = new MessageRpcInvokeNotification(this.Activity, this.channelHandler);
 }
コード例 #38
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), "System.ServiceModel.Dispatcher.MessageRpc.MessageRpc(), operationContext == null");
            Fx.Assert(channelHandler != null, "System.ServiceModel.Dispatcher.MessageRpc.MessageRpc(), channelHandler == null");

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

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

            this.HostingProperty = AspNetEnvironment.Current.GetHostingProperty(request, true);

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

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

            this.InvokeNotification = new MessageRpcInvokeNotification(this.Activity, this.channelHandler);

            if (this.EventTraceActivity == null && FxTrace.Trace.IsEnd2EndActivityTracingEnabled)
            {
                if (this.Request != null)
                {
                    this.EventTraceActivity = EventTraceActivityHelper.TryExtractActivity(this.Request, true);
                }
            }
        }
コード例 #39
0
 private void Dispatch()
 {
     ListenerChannel channel = this.channel;
     ServiceChannel.SessionIdleManager idleManager = this.idleManager;
     this.channel = null;
     this.idleManager = null;
     try
     {
         if (channel != null)
         {
             ChannelHandler handler = new ChannelHandler(this.listenerBinder.MessageVersion, channel.Binder, this.throttle, this, channel.Throttle != null, this.wrappedTransaction, idleManager);
             if (!channel.Binder.HasSession)
             {
                 this.channelDispatcher.Channels.Add(channel.Binder.Channel);
             }
             if (channel.Binder is DuplexChannelBinder)
             {
                 DuplexChannelBinder binder = channel.Binder as DuplexChannelBinder;
                 binder.ChannelHandler = handler;
                 binder.DefaultCloseTimeout = this.DefaultCloseTimeout;
                 if (this.timeouts == null)
                 {
                     binder.DefaultSendTimeout = ServiceDefaults.SendTimeout;
                 }
                 else
                 {
                     binder.DefaultSendTimeout = this.timeouts.SendTimeout;
                 }
             }
             ChannelHandler.Register(handler);
             channel = null;
             idleManager = null;
         }
     }
     catch (Exception exception)
     {
         if (Fx.IsFatal(exception))
         {
             throw;
         }
         this.HandleError(exception);
     }
     finally
     {
         if (channel != null)
         {
             channel.Binder.Channel.Abort();
             if ((this.throttle != null) && this.channelDispatcher.Session)
             {
                 this.throttle.DeactivateChannel();
             }
             if (idleManager != null)
             {
                 idleManager.CancelTimer();
             }
         }
     }
 }
コード例 #40
0
ファイル: ListenerHandler.cs プロジェクト: weshaggard/wcf
        private void Dispatch()
        {
            ListenerChannel channel = _channel;
            SessionIdleManager idleManager = _idleManager;
            _channel = null;
            _idleManager = null;

            try
            {
                if (channel != null)
                {
                    ChannelHandler handler = new ChannelHandler(_listenerBinder.MessageVersion, channel.Binder, this, 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 = this.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;
                }
                this.HandleError(e);
            }
            finally
            {
                if (channel != null)
                {
                    channel.Binder.Channel.Abort();
                    if (idleManager != null)
                    {
                        idleManager.CancelTimer();
                    }
                }
            }
        }
コード例 #41
0
 internal static void Register(ChannelHandler handler, RequestContext request)
 {
     (handler.Binder as BufferedReceiveBinder).InjectRequest(request);
     handler.Register();
 }
コード例 #42
0
        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;
        }
コード例 #43
0
 public static void EnsureReceiveContextAbandonOnTransactionRollback(ReceiveContext receiveContext, Transaction transaction, ChannelHandler channelHandler)
 {
     new TransactionOutcomeListener(receiveContext, transaction, channelHandler);
 }
コード例 #44
0
            public bool ChannelHandlerOwnsInstanceContextThrottle; // if true, we are responsible for instance/dynamic throttle

            public RequestInfo(ChannelHandler channelHandler)
            {
                this.Endpoint = null;
                this.ExistingInstanceContext = null;
                this.Channel = null;
                this.EndpointLookupDone = false;
                this.DispatchRuntime = null;
                this.RequestContext = null;
                this.ChannelHandler = channelHandler;
                this.ChannelHandlerOwnsCallThrottle = false;
                this.ChannelHandlerOwnsInstanceContextThrottle = false;
            }
コード例 #45
0
 public MessageRpcInvokeNotification(ServiceModelActivity activity, ChannelHandler handler)
 {
     _activity = activity;
     _handler  = handler;
 }
コード例 #46
0
 bool PrivateAcquireCall(ChannelHandler channel)
 {
     return (this.calls == null) || this.calls.Acquire(channel);
 }
コード例 #47
0
        internal MessageRpc(RequestContext requestContext, Message request, DispatchOperationRuntime operation,
                            ServiceChannel channel, ChannelHandler channelHandler, bool cleanThread,
                            OperationContext operationContext, InstanceContext instanceContext, EventTraceActivity eventTraceActivity)
        {
            Fx.Assert((operationContext != null), "System.ServiceModel.Dispatcher.MessageRpc.MessageRpc(), operationContext == null");
            Fx.Assert(channelHandler != null, "System.ServiceModel.Dispatcher.MessageRpc.MessageRpc(), channelHandler == null");

            this.Activity           = null;
            this.EventTraceActivity = eventTraceActivity;
            this.AsyncResult        = null;
            this.CanSendReply       = true;
            this.Channel            = channel;
            this.channelHandler     = channelHandler;
            this.Correlation        = EmptyArray <object> .Allocate(operation.Parent.CorrelationCount);

            this.DidDeserializeRequestBody = false;
            this.Error              = null;
            this.ErrorProcessor     = null;
            this.FaultInfo          = new ErrorHandlerFaultInfo(request.Version.Addressing.DefaultFaultAction);
            this.HasSecurityContext = false;
            this.Instance           = null;
            this.MessageRpcOwnsInstanceContextThrottle = false;
            this.NextProcessor        = null;
            this.NotUnderstoodHeaders = null;
            this.Operation            = operation;
            this.OperationContext     = operationContext;
            _paused = false;
            this.ParametersDisposed         = false;
            this.Request                    = request;
            this.RequestContext             = requestContext;
            this.RequestContextThrewOnReply = false;
            this.SuccessfullySendReply      = false;
            this.RequestVersion             = request.Version;
            this.Reply = null;
            this.ReplyTimeoutHelper              = new TimeoutHelper();
            this.SecurityContext                 = null;
            this.InstanceContext                 = instanceContext;
            this.SuccessfullyBoundInstance       = false;
            this.SuccessfullyIncrementedActivity = false;
            this.SuccessfullyLockedInstance      = false;
            _switchedThreads            = !cleanThread;
            this.InputParameters        = null;
            this.OutputParameters       = null;
            this.ReturnParameter        = null;
            _isInstanceContextSingleton = false;
            _invokeContinueGate         = null;

            if (!operation.IsOneWay && !operation.Parent.ManualAddressing)
            {
                this.RequestID   = request.Headers.MessageId;
                this.ReplyToInfo = new RequestReplyCorrelator.ReplyToInfo(request);
            }
            else
            {
                this.RequestID   = null;
                this.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
            {
                this.ResponseActivityId = Guid.Empty;
            }

            this.InvokeNotification = new MessageRpcInvokeNotification(this.Activity, this.channelHandler);

            if (this.EventTraceActivity == null && FxTrace.Trace.IsEnd2EndActivityTracingEnabled)
            {
                if (this.Request != null)
                {
                    this.EventTraceActivity = EventTraceActivityHelper.TryExtractActivity(this.Request, true);
                }
            }
        }
コード例 #48
0
 bool PrivateAcquireDynamic(ChannelHandler channel)
 {
     return (this.dynamic == null) || this.dynamic.Acquire(channel);
 }
コード例 #49
0
 public MessageRpcInvokeNotification(ServiceModelActivity activity, ChannelHandler handler)
 {
     this.activity = activity;
     this.handler = handler;
 }
コード例 #50
0
 bool PrivateAcquireInstanceContext(ChannelHandler channel)
 {
     if ((this.instanceContexts != null) && (channel.InstanceContext == null))
     {
         channel.InstanceContextServiceThrottle = this;
         return this.instanceContexts.Acquire(channel);
     }
     else
     {
         return true;
     }
 }
コード例 #51
0
            public AcknowledgementCompleteAsyncResult(
                ReceiveContext receiveContext,
                TimeSpan timeout,
                ref MessageRpc rpc,
                Transaction transaction,
                AsyncCallback callback,
                object state) : base(callback, state)
            {
                this.receiveContext = receiveContext;
                this.currentTransaction = transaction;
                this.channelHandler = rpc.channelHandler;
                this.resumableRPC = rpc.Pause();

                bool completeThrew = true;
                try
                {
                    bool completed = this.Complete(timeout);
                    completeThrew = false;

                    if (completed)
                    {
                        this.resumableRPC = null;
                        rpc.UnPause();
                        this.Complete(true);
                    }
                }
                finally
                {
                    if (completeThrew)
                    {
                        rpc.UnPause();
                    }
                }
            }
コード例 #52
0
 private bool PrivateAcquireCall(ChannelHandler channel)
 {
     if (this.calls != null)
     {
         return this.calls.Acquire(channel);
     }
     return true;
 }
コード例 #53
0
 public static void EnsureReceiveContextAbandonOnTransactionRollback(ReceiveContext receiveContext, Transaction transaction, ChannelHandler channelHandler)
 {
     new TransactionOutcomeListener(receiveContext, transaction, channelHandler);
 }
コード例 #54
0
 public TransactionOutcomeListener(ReceiveContext receiveContext, Transaction transaction, ChannelHandler handler)
 {
     this.receiveContext = receiveContext;
     transaction.TransactionCompleted += new TransactionCompletedEventHandler(this.OnTransactionComplete);
     this.channelHandler = handler;
 }