public void OnLocalFault(Exception e, Message faultMessage, RequestContext context)
 {
     if ((this.channel.Aborted || (this.channel.State == CommunicationState.Faulted)) || (this.channel.State == CommunicationState.Closed))
     {
         if (faultMessage != null)
         {
             faultMessage.Close();
         }
         if (context != null)
         {
             context.Abort();
         }
     }
     else
     {
         lock (this.ThisLock)
         {
             if (this.faulted != SessionFaultState.NotFaulted)
             {
                 return;
             }
             this.faulted           = SessionFaultState.LocallyFaulted;
             this.terminatingFault  = faultMessage;
             this.replyFaultContext = context;
         }
         this.FaultCore();
         this.channel.Fault(e);
         this.UnblockChannelIfNecessary();
     }
 }
 private void AbortRequestContext(System.ServiceModel.Channels.RequestContext requestContext)
 {
     try
     {
         requestContext.Abort();
         ReceiveContextRPCFacet receiveContext = this.ReceiveContext;
         if (receiveContext != null)
         {
             this.ReceiveContext = null;
             CallbackState state = new CallbackState {
                 ReceiveContext = receiveContext,
                 ChannelHandler = this.channelHandler
             };
             IAsyncResult result = receiveContext.BeginAbandon(TimeSpan.MaxValue, handleEndAbandon, state);
             if (result.CompletedSynchronously)
             {
                 receiveContext.EndAbandon(result);
             }
         }
     }
     catch (Exception exception)
     {
         if (Fx.IsFatal(exception))
         {
             throw;
         }
         this.channelHandler.HandleError(exception);
     }
 }
 protected override void ProcessSequencedItem(IReplySessionChannel channel, RequestContext context, ReliableInputSessionChannelOverReply reliableChannel, WsrmMessageInfo info, bool newChannel)
 {
     if (!newChannel && !reliableChannel.Binder.UseNewChannel(channel))
     {
         context.RequestMessage.Close();
         context.Abort();
         channel.Abort();
     }
     else
     {
         reliableChannel.ProcessDemuxedRequest(reliableChannel.Binder.WrapRequestContext(context), info);
     }
 }
Exemple #4
0
            private Message ProcessContext(RequestContext context, TimeSpan timeout)
            {
                if (context == null)
                {
                    return(null);
                }
                bool    flag           = false;
                Message requestMessage = null;

                try
                {
                    requestMessage = context.RequestMessage;
                    requestMessage.Properties.Add(RequestContextMessageProperty.Name, new RequestContextMessageProperty(context));
                    if (this.validateHeader)
                    {
                        PacketRoutableHeader.ValidateMessage(requestMessage);
                    }
                    try
                    {
                        context.Reply(null, new TimeoutHelper(timeout).RemainingTime());
                        flag = true;
                    }
                    catch (CommunicationException exception)
                    {
                        if (DiagnosticUtility.ShouldTraceInformation)
                        {
                            DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information);
                        }
                    }
                    catch (TimeoutException exception2)
                    {
                        if (DiagnosticUtility.ShouldTraceInformation)
                        {
                            DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information);
                        }
                    }
                }
                finally
                {
                    if (!flag)
                    {
                        context.Abort();
                        if (requestMessage != null)
                        {
                            requestMessage.Close();
                            requestMessage = null;
                        }
                    }
                }
                return(requestMessage);
            }
Exemple #5
0
        void IDisposable.Dispose()
        {
            RequestContext context;
            bool           flag = false;

            lock (this.thisLock)
            {
                if (this.context == null)
                {
                    return;
                }
                context      = this.context;
                this.context = null;
            }
            try
            {
                context.Close();
                flag = true;
            }
            catch (CommunicationException exception)
            {
                if (DiagnosticUtility.ShouldTraceInformation)
                {
                    DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information);
                }
            }
            catch (TimeoutException exception2)
            {
                if (DiagnosticUtility.ShouldTraceInformation)
                {
                    DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information);
                }
            }
            finally
            {
                if (!flag)
                {
                    context.Abort();
                }
            }
        }
 void IDisposable.Dispose()
 {
     RequestContext context;
     bool flag = false;
     lock (this.thisLock)
     {
         if (this.context == null)
         {
             return;
         }
         context = this.context;
         this.context = null;
     }
     try
     {
         context.Close();
         flag = true;
     }
     catch (CommunicationException exception)
     {
         if (DiagnosticUtility.ShouldTraceInformation)
         {
             DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information);
         }
     }
     catch (TimeoutException exception2)
     {
         if (DiagnosticUtility.ShouldTraceInformation)
         {
             DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information);
         }
     }
     finally
     {
         if (!flag)
         {
             context.Abort();
         }
     }
 }
        void AbortRequestContext(RequestContext requestContext)
        {
            try
            {
                requestContext.Abort();

                ReceiveContextRPCFacet receiveContext = this.ReceiveContext;

                if (receiveContext != null)
                {
                    this.ReceiveContext = null;
                    IAsyncResult result = receiveContext.BeginAbandon(
                        TimeSpan.MaxValue,
                        handleEndAbandon,
                        new CallbackState
                        {
                            ReceiveContext = receiveContext,
                            ChannelHandler = this.channelHandler
                        });

                    if (result.CompletedSynchronously)
                    {
                        receiveContext.EndAbandon(result);
                    }
                }
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                this.channelHandler.HandleError(e);
            }
        }
        bool HandleErrorContinuation(Exception e, RequestContext request, ServiceChannel channel, ref ErrorHandlerFaultInfo faultInfo, bool replied)
        {
            if (replied)
            {
                try
                {
                    request.Close();
                }
                catch (Exception e1)
                {
                    if (Fx.IsFatal(e1))
                    {
                        throw;
                    }
                    this.HandleError(e1);
                }
            }
            else
            {
                request.Abort();
            }
            if (!this.HandleError(e, ref faultInfo) && this.hasSession)
            {
                if (channel != null)
                {
                    if (replied)
                    {
                        TimeoutHelper timeoutHelper = new TimeoutHelper(CloseAfterFaultTimeout);
                        try
                        {
                            channel.Close(timeoutHelper.RemainingTime());
                        }
                        catch (Exception e2)
                        {
                            if (Fx.IsFatal(e2))
                            {
                                throw;
                            }
                            this.HandleError(e2);
                        }
                        try
                        {
                            this.binder.CloseAfterFault(timeoutHelper.RemainingTime());
                        }
                        catch (Exception e3)
                        {
                            if (Fx.IsFatal(e3))
                            {
                                throw;
                            }
                            this.HandleError(e3);
                        }
                    }
                    else
                    {
                        channel.Abort();
                        this.binder.Abort();
                    }
                }
                else
                {
                    if (replied)
                    {
                        try
                        {
                            this.binder.CloseAfterFault(CloseAfterFaultTimeout);
                        }
                        catch (Exception e4)
                        {
                            if (Fx.IsFatal(e4))
                            {
                                throw;
                            }
                            this.HandleError(e4);
                        }
                    }
                    else
                    {
                        this.binder.Abort();
                    }
                }
            }

            return true;
        }
        bool TryRetrievingInstanceContext(RequestContext request)
        {
            try
            {
                return TryRetrievingInstanceContextCore(request);
            }
            catch (Exception ex)
            {
                if (Fx.IsFatal(ex))
                {
                    throw;
                }

                DiagnosticUtility.TraceHandledException(ex, TraceEventType.Error);

                try
                {
                    request.Close();
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }

                    request.Abort();
                }

                return false;
            }
        }
        public void OnLocalFault(Exception e, Message faultMessage, RequestContext context)
        {
            if (this.channel.Aborted ||
                this.channel.State == CommunicationState.Faulted ||
                this.channel.State == CommunicationState.Closed)
            {
                if (faultMessage != null)
                    faultMessage.Close();
                if (context != null)
                    context.Abort();
                return;
            }

            lock (this.ThisLock)
            {
                if (this.faulted != SessionFaultState.NotFaulted)
                    return;
                this.faulted = SessionFaultState.LocallyFaulted;
                this.terminatingFault = faultMessage;
                this.replyFaultContext = context;
            }

            this.FaultCore();
            this.channel.Fault(e);
            this.UnblockChannelIfNecessary();
        }
Exemple #11
0
 private void AbortRequestContext(RequestContext requestContext)
 {
     try
     {
         requestContext.Abort();
     }
     catch (Exception e)
     {
         if (Fx.IsFatal(e))
         {
             throw;
         }
         this.channelHandler.HandleError(e);
     }
 }
Exemple #12
0
        bool HandleRequest(IReplyChannel channel, RequestContext context)
        {
            if (context == null)
            {
                channel.Close();
                return false;
            }

            try
            {
                serviceManager.HandleRequest(context);
            }
            catch (CommunicationException)
            {
                context.Abort();
            }
            finally
            {
                context.Close();
            }
            return true;
        }
 private bool HandleError(Exception e, RequestContext request, ServiceChannel channel)
 {
     bool flag;
     ErrorHandlerFaultInfo faultInfo = new ErrorHandlerFaultInfo(this.messageVersion.Addressing.DefaultFaultAction);
     this.ProvideFaultAndReplyFailure(request, e, ref faultInfo, out flag);
     if (flag)
     {
         try
         {
             request.Close();
         }
         catch (Exception exception)
         {
             if (Fx.IsFatal(exception))
             {
                 throw;
             }
             this.HandleError(exception);
         }
     }
     else
     {
         request.Abort();
     }
     if (!this.HandleError(e, ref faultInfo) && this.hasSession)
     {
         if (channel != null)
         {
             if (flag)
             {
                 TimeoutHelper helper = new TimeoutHelper(CloseAfterFaultTimeout);
                 try
                 {
                     channel.Close(helper.RemainingTime());
                 }
                 catch (Exception exception2)
                 {
                     if (Fx.IsFatal(exception2))
                     {
                         throw;
                     }
                     this.HandleError(exception2);
                 }
                 try
                 {
                     this.binder.CloseAfterFault(helper.RemainingTime());
                     goto Label_0117;
                 }
                 catch (Exception exception3)
                 {
                     if (Fx.IsFatal(exception3))
                     {
                         throw;
                     }
                     this.HandleError(exception3);
                     goto Label_0117;
                 }
             }
             channel.Abort();
             this.binder.Abort();
         }
         else
         {
             if (flag)
             {
                 try
                 {
                     this.binder.CloseAfterFault(CloseAfterFaultTimeout);
                     goto Label_0117;
                 }
                 catch (Exception exception4)
                 {
                     if (Fx.IsFatal(exception4))
                     {
                         throw;
                     }
                     this.HandleError(exception4);
                     goto Label_0117;
                 }
             }
             this.binder.Abort();
         }
     }
 Label_0117:
     return true;
 }
 public override void Abort()
 {
     source.Abort();
 }