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();
     }
 }
        public virtual void OnFaulted()
        {
            bool flag;

            this.FaultCore();
            lock (this.ThisLock)
            {
                if ((this.faulted == SessionFaultState.NotFaulted) || (this.faulted == SessionFaultState.CleanedUp))
                {
                    return;
                }
                flag         = this.canSendFault && (this.faulted != SessionFaultState.RemotelyFaulted);
                this.faulted = SessionFaultState.CleanedUp;
            }
            if ((((!flag || (this.binder.State != CommunicationState.Opened)) || !this.binder.Connected) || (!this.binder.CanSendAsynchronously && (this.replyFaultContext == null))) || (this.terminatingFault == null))
            {
                if (this.terminatingFault != null)
                {
                    this.terminatingFault.Close();
                }
                if (this.replyFaultContext != null)
                {
                    this.replyFaultContext.Abort();
                }
                this.binder.Abort();
            }
            else
            {
                this.AddFinalRanges();
                this.faultHelper.SendFaultAsync(this.binder, this.replyFaultContext, this.terminatingFault);
            }
        }
Ejemplo n.º 3
0
        public virtual void Abort()
        {
            this.guard.Abort();
            this.inactivityTimer.Abort();

            // Try to send a fault.
            bool sendFault;

            lock (this.ThisLock)
            {
                // Faulted thread already cleaned up. No need to to anything more.
                if (this.faulted == SessionFaultState.CleanedUp)
                {
                    return;
                }

                // Can only send a fault if the other side did not send one already.
                sendFault    = this.canSendFault && (this.faulted != SessionFaultState.RemotelyFaulted); // NotFaulted || LocallyFaulted
                this.faulted = SessionFaultState.CleanedUp;
            }

            if (sendFault)
            {
                if ((this.binder.State == CommunicationState.Opened) &&
                    this.binder.Connected &&
                    (this.binder.CanSendAsynchronously || (this.replyFaultContext != null)))
                {
                    if (this.terminatingFault == null)
                    {
                        UniqueId sequenceId = this.InputID ?? this.OutputID;
                        if (sequenceId != null)
                        {
                            WsrmFault fault = SequenceTerminatedFault.CreateCommunicationFault(sequenceId, SR.GetString(SR.SequenceTerminatedOnAbort), null);
                            this.terminatingFault = fault.CreateMessage(this.settings.MessageVersion,
                                                                        this.settings.ReliableMessagingVersion);
                        }
                    }

                    if (this.terminatingFault != null)
                    {
                        this.AddFinalRanges();
                        this.faultHelper.SendFaultAsync(this.binder, this.replyFaultContext, this.terminatingFault);
                        return;
                    }
                }
            }

            // Got here so the session did not actually send a fault, must clean up resources.
            if (this.terminatingFault != null)
            {
                this.terminatingFault.Close();
            }
            if (this.replyFaultContext != null)
            {
                this.replyFaultContext.Abort();
            }
            this.binder.Abort();
        }
Ejemplo n.º 4
0
        public virtual void OnFaulted()
        {
            this.FaultCore();

            // Try to send a fault.
            bool sendFault;

            lock (this.ThisLock)
            {
                // Channel was faulted without the session being told first (e.g. open throws).
                // The session does not know what fault to send so let abort send it if it can.
                if (this.faulted == SessionFaultState.NotFaulted)
                {
                    return;
                }

                // Abort thread decided to clean up.
                if (this.faulted == SessionFaultState.CleanedUp)
                {
                    return;
                }

                // Can only send a fault if the other side did not send one already.
                sendFault    = this.canSendFault && (this.faulted != SessionFaultState.RemotelyFaulted); // LocallyFaulted
                this.faulted = SessionFaultState.CleanedUp;
            }

            if (sendFault)
            {
                if ((this.binder.State == CommunicationState.Opened) &&
                    this.binder.Connected &&
                    (this.binder.CanSendAsynchronously || (this.replyFaultContext != null)) &&
                    (this.terminatingFault != null))
                {
                    this.AddFinalRanges();
                    this.faultHelper.SendFaultAsync(this.binder, this.replyFaultContext, this.terminatingFault);
                    return;
                }
            }

            // Got here so the session did not actually send a fault, must clean up resources.
            if (this.terminatingFault != null)
            {
                this.terminatingFault.Close();
            }
            if (this.replyFaultContext != null)
            {
                this.replyFaultContext.Abort();
            }
            this.binder.Abort();
        }
 public void OnRemoteFault(Exception e)
 {
     if ((!this.channel.Aborted && (this.channel.State != CommunicationState.Faulted)) && (this.channel.State != CommunicationState.Closed))
     {
         lock (this.ThisLock)
         {
             if (this.faulted != SessionFaultState.NotFaulted)
             {
                 return;
             }
             this.faulted = SessionFaultState.RemotelyFaulted;
         }
         this.FaultCore();
         this.channel.Fault(e);
         this.UnblockChannelIfNecessary();
     }
 }
        public virtual void Abort()
        {
            bool flag;

            this.guard.Abort();
            this.inactivityTimer.Abort();
            lock (this.ThisLock)
            {
                if (this.faulted == SessionFaultState.CleanedUp)
                {
                    return;
                }
                flag         = this.canSendFault && (this.faulted != SessionFaultState.RemotelyFaulted);
                this.faulted = SessionFaultState.CleanedUp;
            }
            if (((flag && (this.binder.State == CommunicationState.Opened)) && this.binder.Connected) && (this.binder.CanSendAsynchronously || (this.replyFaultContext != null)))
            {
                if (this.terminatingFault == null)
                {
                    UniqueId sequenceID = this.InputID ?? this.OutputID;
                    if (sequenceID != null)
                    {
                        this.terminatingFault = SequenceTerminatedFault.CreateCommunicationFault(sequenceID, System.ServiceModel.SR.GetString("SequenceTerminatedOnAbort"), null).CreateMessage(this.settings.MessageVersion, this.settings.ReliableMessagingVersion);
                    }
                }
                if (this.terminatingFault != null)
                {
                    this.AddFinalRanges();
                    this.faultHelper.SendFaultAsync(this.binder, this.replyFaultContext, this.terminatingFault);
                    return;
                }
            }
            if (this.terminatingFault != null)
            {
                this.terminatingFault.Close();
            }
            if (this.replyFaultContext != null)
            {
                this.replyFaultContext.Abort();
            }
            this.binder.Abort();
        }
 public virtual void Abort()
 {
     bool flag;
     this.guard.Abort();
     this.inactivityTimer.Abort();
     lock (this.ThisLock)
     {
         if (this.faulted == SessionFaultState.CleanedUp)
         {
             return;
         }
         flag = this.canSendFault && (this.faulted != SessionFaultState.RemotelyFaulted);
         this.faulted = SessionFaultState.CleanedUp;
     }
     if (((flag && (this.binder.State == CommunicationState.Opened)) && this.binder.Connected) && (this.binder.CanSendAsynchronously || (this.replyFaultContext != null)))
     {
         if (this.terminatingFault == null)
         {
             UniqueId sequenceID = this.InputID ?? this.OutputID;
             if (sequenceID != null)
             {
                 this.terminatingFault = SequenceTerminatedFault.CreateCommunicationFault(sequenceID, System.ServiceModel.SR.GetString("SequenceTerminatedOnAbort"), null).CreateMessage(this.settings.MessageVersion, this.settings.ReliableMessagingVersion);
             }
         }
         if (this.terminatingFault != null)
         {
             this.AddFinalRanges();
             this.faultHelper.SendFaultAsync(this.binder, this.replyFaultContext, this.terminatingFault);
             return;
         }
     }
     if (this.terminatingFault != null)
     {
         this.terminatingFault.Close();
     }
     if (this.replyFaultContext != null)
     {
         this.replyFaultContext.Abort();
     }
     this.binder.Abort();
 }
        public virtual void OnFaulted()
        {
            this.FaultCore();

            // Try to send a fault.
            bool sendFault;
            lock (this.ThisLock)
            {
                // Channel was faulted without the session being told first (e.g. open throws).
                // The session does not know what fault to send so let abort send it if it can.
                if (this.faulted == SessionFaultState.NotFaulted)
                    return;

                // Abort thread decided to clean up.
                if (this.faulted == SessionFaultState.CleanedUp)
                    return;

                // Can only send a fault if the other side did not send one already.
                sendFault = this.canSendFault && (this.faulted != SessionFaultState.RemotelyFaulted);  // LocallyFaulted
                this.faulted = SessionFaultState.CleanedUp;
            }

            if (sendFault)
            {
                if ((this.binder.State == CommunicationState.Opened)
                    && this.binder.Connected
                    && (this.binder.CanSendAsynchronously || (this.replyFaultContext != null))
                    && (this.terminatingFault != null))
                {
                    this.AddFinalRanges();
                    this.faultHelper.SendFaultAsync(this.binder, this.replyFaultContext, this.terminatingFault);
                    return;
                }
            }

            // Got here so the session did not actually send a fault, must clean up resources.
            if (this.terminatingFault != null)
                this.terminatingFault.Close();
            if (this.replyFaultContext != null)
                this.replyFaultContext.Abort();
            this.binder.Abort();
        }
        public void OnRemoteFault(Exception e)
        {
            if (this.channel.Aborted ||
                this.channel.State == CommunicationState.Faulted ||
                this.channel.State == CommunicationState.Closed)
            {
                return;
            }

            lock (this.ThisLock)
            {
                if (this.faulted != SessionFaultState.NotFaulted)
                    return;
                this.faulted = SessionFaultState.RemotelyFaulted;
            }

            this.FaultCore();
            this.channel.Fault(e);
            this.UnblockChannelIfNecessary();
        }
        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();
        }
        public virtual void Abort()
        {
            this.guard.Abort();
            this.inactivityTimer.Abort();

            // Try to send a fault.
            bool sendFault;
            lock (this.ThisLock)
            {
                // Faulted thread already cleaned up. No need to to anything more.
                if (this.faulted == SessionFaultState.CleanedUp)
                    return;

                // Can only send a fault if the other side did not send one already.
                sendFault = this.canSendFault && (this.faulted != SessionFaultState.RemotelyFaulted);    // NotFaulted || LocallyFaulted
                this.faulted = SessionFaultState.CleanedUp;
            }

            if (sendFault)
            {
                if ((this.binder.State == CommunicationState.Opened)
                    && this.binder.Connected
                    && (this.binder.CanSendAsynchronously || (this.replyFaultContext != null)))
                {
                    if (this.terminatingFault == null)
                    {
                        UniqueId sequenceId = this.InputID ?? this.OutputID;
                        if (sequenceId != null)
                        {
                            WsrmFault fault = SequenceTerminatedFault.CreateCommunicationFault(sequenceId, SR.GetString(SR.SequenceTerminatedOnAbort), null);
                            this.terminatingFault = fault.CreateMessage(this.settings.MessageVersion,
                                this.settings.ReliableMessagingVersion);
                        }
                    }

                    if (this.terminatingFault != null)
                    {
                        this.AddFinalRanges();
                        this.faultHelper.SendFaultAsync(this.binder, this.replyFaultContext, this.terminatingFault);
                        return;
                    }
                }
            }

            // Got here so the session did not actually send a fault, must clean up resources.
            if (this.terminatingFault != null)
                this.terminatingFault.Close();
            if (this.replyFaultContext != null)
                this.replyFaultContext.Abort();
            this.binder.Abort();
        }
 public virtual void OnFaulted()
 {
     bool flag;
     this.FaultCore();
     lock (this.ThisLock)
     {
         if ((this.faulted == SessionFaultState.NotFaulted) || (this.faulted == SessionFaultState.CleanedUp))
         {
             return;
         }
         flag = this.canSendFault && (this.faulted != SessionFaultState.RemotelyFaulted);
         this.faulted = SessionFaultState.CleanedUp;
     }
     if ((((!flag || (this.binder.State != CommunicationState.Opened)) || !this.binder.Connected) || (!this.binder.CanSendAsynchronously && (this.replyFaultContext == null))) || (this.terminatingFault == null))
     {
         if (this.terminatingFault != null)
         {
             this.terminatingFault.Close();
         }
         if (this.replyFaultContext != null)
         {
             this.replyFaultContext.Abort();
         }
         this.binder.Abort();
     }
     else
     {
         this.AddFinalRanges();
         this.faultHelper.SendFaultAsync(this.binder, this.replyFaultContext, this.terminatingFault);
     }
 }