Example #1
0
        public void Committed()
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                               "SinglePhaseEnlistment.Committed"
                                               );
                EnlistmentCallbackPositiveTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                                            this.internalEnlistment.EnlistmentTraceId,
                                                            EnlistmentCallback.Committed
                                                            );
            }

            lock (this.internalEnlistment.SyncRoot)
            {
                this.internalEnlistment.State.Committed(this.internalEnlistment);
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                              "SinglePhaseEnlistment.Committed"
                                              );
            }
        }
Example #2
0
        public void Done()
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                               "Enlistment.Done"
                                               );
                EnlistmentCallbackPositiveTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                                            this.internalEnlistment.EnlistmentTraceId,
                                                            EnlistmentCallback.Done
                                                            );
            }

            lock (this.internalEnlistment.SyncRoot)
            {
                this.internalEnlistment.State.EnlistmentDone(this.internalEnlistment);
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                              "Enlistment.Done"
                                              );
            }
        }
Example #3
0
        void IPromotedEnlistment.EnlistmentDone()
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxEnlistment.EnlistmentDone");
                EnlistmentCallbackPositiveTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentCallback.Done);
            }
            OletxVolatileEnlistmentState     active    = OletxVolatileEnlistmentState.Active;
            OletxVolatileEnlistmentContainer container = null;

            lock (this)
            {
                active    = this.state;
                container = this.container;
                if ((((this.state != OletxVolatileEnlistmentState.Active) && (OletxVolatileEnlistmentState.Preparing != this.state)) && ((OletxVolatileEnlistmentState.Aborting != this.state) && (OletxVolatileEnlistmentState.Committing != this.state))) && (OletxVolatileEnlistmentState.InDoubt != this.state))
                {
                    throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
                }
                this.state = OletxVolatileEnlistmentState.Done;
            }
            if ((OletxVolatileEnlistmentState.Preparing == active) && (container != null))
            {
                container.DecrementOutstandingNotifications(true);
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxEnlistment.EnlistmentDone");
            }
        }
Example #4
0
        void IPromotedEnlistment.Prepared()
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxPreparingEnlistment.Prepared");
                EnlistmentCallbackPositiveTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentCallback.Prepared);
            }
            OletxVolatileEnlistmentContainer container = null;
            TransactionStatus active = TransactionStatus.Active;

            lock (this)
            {
                if (OletxVolatileEnlistmentState.Preparing != this.state)
                {
                    throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
                }
                this.state = OletxVolatileEnlistmentState.Prepared;
                active     = this.pendingOutcome;
                if (this.container == null)
                {
                    if (DiagnosticTrace.Critical)
                    {
                        InternalErrorTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "");
                    }
                    throw new InvalidOperationException(System.Transactions.SR.GetString("InternalError"));
                }
                container = this.container;
            }
            container.DecrementOutstandingNotifications(true);
            switch (active)
            {
            case TransactionStatus.Active:
                break;

            case TransactionStatus.Aborted:
                this.Rollback();
                break;

            case TransactionStatus.InDoubt:
                this.InDoubt();
                break;

            default:
                if (DiagnosticTrace.Critical)
                {
                    InternalErrorTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "");
                }
                throw new InvalidOperationException(System.Transactions.SR.GetString("InternalError"));
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxPreparingEnlistment.Prepared");
            }
        }
 public void Prepared()
 {
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "PreparingEnlistment.Prepared");
         EnlistmentCallbackPositiveTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), base.internalEnlistment.EnlistmentTraceId, EnlistmentCallback.Prepared);
     }
     lock (base.internalEnlistment.SyncRoot)
     {
         base.internalEnlistment.State.Prepared(base.internalEnlistment);
     }
     if (DiagnosticTrace.Verbose)
     {
         MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "PreparingEnlistment.Prepared");
     }
 }
        public void Committed()
        {
            IEnlistmentShim enlistmentShim = null;

            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxSinglePhaseEnlistment.Committed");
                EnlistmentCallbackPositiveTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentCallback.Committed);
            }
            lock (this)
            {
                if (!this.isSinglePhase || (OletxEnlistmentState.SinglePhaseCommitting != this.state))
                {
                    throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
                }
                this.state     = OletxEnlistmentState.Committed;
                enlistmentShim = this.EnlistmentShim;
            }
            try
            {
                if (enlistmentShim != null)
                {
                    enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.SinglePhase);
                }
            }
            catch (COMException exception)
            {
                if ((System.Transactions.Oletx.NativeMethods.XACT_E_CONNECTION_DOWN != exception.ErrorCode) && (System.Transactions.Oletx.NativeMethods.XACT_E_TMNOTAVAILABLE != exception.ErrorCode))
                {
                    throw;
                }
                if (DiagnosticTrace.Verbose)
                {
                    ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
                }
            }
            finally
            {
                this.FinishEnlistment();
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxSinglePhaseEnlistment.Committed");
            }
        }
Example #7
0
        public void Prepared()
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceLtm, "PreparingEnlistment.Prepared");
                EnlistmentCallbackPositiveTraceRecord.Trace(SR.TraceSourceLtm,
                                                            _internalEnlistment.EnlistmentTraceId, EnlistmentCallback.Prepared);
            }

            lock (_internalEnlistment.SyncRoot)
            {
                _internalEnlistment.State.Prepared(_internalEnlistment);
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.TraceSourceLtm, "PreparingEnlistment.Prepared");
            }
        }
        public void Prepared()
        {
            int                   num1              = System.Transactions.Oletx.NativeMethods.S_OK;
            IEnlistmentShim       enlistmentShim    = null;
            IPhase0EnlistmentShim shim              = null;
            bool                  fabricateRollback = false;

            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxPreparingEnlistment.Prepared");
                EnlistmentCallbackPositiveTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentCallback.Prepared);
            }
            lock (this)
            {
                if (OletxEnlistmentState.Preparing == this.state)
                {
                    enlistmentShim = this.EnlistmentShim;
                }
                else
                {
                    if (OletxEnlistmentState.Phase0Preparing != this.state)
                    {
                        throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
                    }
                    shim = this.Phase0EnlistmentShim;
                    if (base.oletxTransaction.realOletxTransaction.Doomed || this.fabricateRollback)
                    {
                        this.fabricateRollback = true;
                        fabricateRollback      = this.fabricateRollback;
                    }
                }
                this.state = OletxEnlistmentState.Prepared;
            }
            try
            {
                if (enlistmentShim != null)
                {
                    enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.Prepared);
                }
                else if (shim != null)
                {
                    base.oletxTransaction.realOletxTransaction.DecrementUndecidedEnlistments();
                    shim.Phase0Done(!fabricateRollback);
                }
                else
                {
                    fabricateRollback = true;
                }
                if (fabricateRollback)
                {
                    this.AbortRequest();
                }
            }
            catch (COMException exception)
            {
                if ((System.Transactions.Oletx.NativeMethods.XACT_E_CONNECTION_DOWN == exception.ErrorCode) || (System.Transactions.Oletx.NativeMethods.XACT_E_TMNOTAVAILABLE == exception.ErrorCode))
                {
                    if (DiagnosticTrace.Verbose)
                    {
                        ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
                    }
                }
                else
                {
                    if (System.Transactions.Oletx.NativeMethods.XACT_E_PROTOCOL != exception.ErrorCode)
                    {
                        throw;
                    }
                    this.Phase0EnlistmentShim = null;
                    if (DiagnosticTrace.Verbose)
                    {
                        ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
                    }
                }
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxPreparingEnlistment.Prepared");
            }
        }
        public void EnlistmentDone()
        {
            bool flag;

            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxEnlistment.EnlistmentDone");
                EnlistmentCallbackPositiveTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, EnlistmentCallback.Done);
            }
            IEnlistmentShim       enlistmentShim = null;
            IPhase0EnlistmentShim shim2          = null;
            OletxEnlistmentState  active         = OletxEnlistmentState.Active;
            bool fabricateRollback = false;

            lock (this)
            {
                active = this.state;
                if (this.state == OletxEnlistmentState.Active)
                {
                    shim2 = this.Phase0EnlistmentShim;
                    if (shim2 != null)
                    {
                        base.oletxTransaction.realOletxTransaction.DecrementUndecidedEnlistments();
                    }
                    flag = false;
                }
                else if (OletxEnlistmentState.Preparing == this.state)
                {
                    enlistmentShim = this.EnlistmentShim;
                    flag           = true;
                }
                else if (OletxEnlistmentState.Phase0Preparing == this.state)
                {
                    shim2 = this.Phase0EnlistmentShim;
                    base.oletxTransaction.realOletxTransaction.DecrementUndecidedEnlistments();
                    if (this.fabricateRollback)
                    {
                        flag = true;
                    }
                    else
                    {
                        flag = false;
                    }
                }
                else
                {
                    if (((OletxEnlistmentState.Committing != this.state) && (OletxEnlistmentState.Aborting != this.state)) && (OletxEnlistmentState.SinglePhaseCommitting != this.state))
                    {
                        throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
                    }
                    enlistmentShim = this.EnlistmentShim;
                    flag           = true;
                }
                fabricateRollback = this.fabricateRollback;
                this.state        = OletxEnlistmentState.Done;
            }
            try
            {
                if (enlistmentShim != null)
                {
                    if (OletxEnlistmentState.Preparing == active)
                    {
                        try
                        {
                            enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.ReadOnly);
                            goto Label_01C1;
                        }
                        finally
                        {
                            HandleTable.FreeHandle(this.phase1Handle);
                        }
                    }
                    if (OletxEnlistmentState.Committing != active)
                    {
                        if (OletxEnlistmentState.Aborting != active)
                        {
                            if (OletxEnlistmentState.SinglePhaseCommitting != active)
                            {
                                throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
                            }
                            enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.SinglePhase);
                        }
                        else if (!fabricateRollback)
                        {
                            enlistmentShim.AbortRequestDone();
                        }
                    }
                    else
                    {
                        enlistmentShim.CommitRequestDone();
                    }
                }
                else if (shim2 != null)
                {
                    if (active != OletxEnlistmentState.Active)
                    {
                        if (OletxEnlistmentState.Phase0Preparing != active)
                        {
                            throw TransactionException.CreateEnlistmentStateException(System.Transactions.SR.GetString("TraceSourceOletx"), null);
                        }
                        shim2.Phase0Done(true);
                    }
                    else
                    {
                        shim2.Unenlist();
                    }
                }
            }
            catch (COMException exception)
            {
                flag = true;
                if (DiagnosticTrace.Verbose)
                {
                    ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
                }
            }
            finally
            {
                if (flag)
                {
                    this.FinishEnlistment();
                }
            }
Label_01C1:
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxEnlistment.EnlistmentDone");
            }
        }