internal override void CompleteAbortingClone(InternalTransaction tx)
 {
     if (tx.phase1Volatiles.VolatileDemux != null)
     {
         tx.phase1Volatiles.dependentClones--;
     }
     else
     {
         tx.abortingDependentCloneCount--;
         if (tx.abortingDependentCloneCount == 0)
         {
             OletxDependentTransaction abortingDependentClone = tx.abortingDependentClone;
             tx.abortingDependentClone = null;
             Monitor.Exit(tx);
             try
             {
                 try
                 {
                     abortingDependentClone.Complete();
                 }
                 finally
                 {
                     abortingDependentClone.Dispose();
                 }
             }
             finally
             {
                 Monitor.Enter(tx);
             }
         }
     }
 }
 internal override void EnterState(InternalTransaction tx)
 {
     if (tx.needPulse)
     {
         Monitor.Pulse(tx);
     }
 }
Exemple #3
0
        internal bool Add(InternalTransaction tx)
        {
            int currentIndex = Interlocked.Increment(ref _index);
            if (currentIndex < _size)
            {
                tx._tableBucket = this;
                tx._bucketIndex = currentIndex;
                Interlocked.MemoryBarrier(); // This data must be written before the transaction
                                             // could be timed out.
                _transactions[currentIndex] = tx;

                if (_timedOut)
                {
                    lock (tx)
                    {
                        tx.State.Timeout(tx);
                    }
                }
            }
            else
            {
                Bucket newBucket = new Bucket(_owningSet);
                newBucket.nextBucketWeak = new WeakReference(this);

                Bucket oldBucket = Interlocked.CompareExchange(ref _owningSet.headBucket, newBucket, this);
                if (oldBucket == this)
                {
                    // ladies and gentlemen we have a winner.
                    _previous = newBucket;
                }

                return false;
            }
            return true;
        }
 internal OletxTransaction PSPEPromote(InternalTransaction tx)
 {
     TransactionState state = tx.State;
     base.CommonEnterState(tx);
     OletxTransaction oletxTransactionFromTransmitterPropigationToken = null;
     try
     {
         byte[] propagationToken = tx.promoter.Promote();
         if (propagationToken == null)
         {
             throw TransactionException.CreateInvalidOperationException(System.Transactions.SR.GetString("TraceSourceLtm"), System.Transactions.SR.GetString("PromotedReturnedInvalidValue"), null);
         }
         try
         {
             oletxTransactionFromTransmitterPropigationToken = TransactionInterop.GetOletxTransactionFromTransmitterPropigationToken(propagationToken);
         }
         catch (ArgumentException exception)
         {
             throw TransactionException.CreateInvalidOperationException(System.Transactions.SR.GetString("TraceSourceLtm"), System.Transactions.SR.GetString("PromotedReturnedInvalidValue"), exception);
         }
         if (TransactionManager.FindPromotedTransaction(oletxTransactionFromTransmitterPropigationToken.Identifier) != null)
         {
             oletxTransactionFromTransmitterPropigationToken.Dispose();
             throw TransactionException.CreateInvalidOperationException(System.Transactions.SR.GetString("TraceSourceLtm"), System.Transactions.SR.GetString("PromotedTransactionExists"), null);
         }
     }
     finally
     {
         state.CommonEnterState(tx);
     }
     return oletxTransactionFromTransmitterPropigationToken;
 }
 internal bool Add(InternalTransaction tx)
 {
     int index = Interlocked.Increment(ref this.index);
     if (index < this.size)
     {
         tx.tableBucket = this;
         tx.bucketIndex = index;
         Thread.MemoryBarrier();
         this.transactions[index] = tx;
         if (!this.timedOut)
         {
             goto Label_0097;
         }
         lock (tx)
         {
             tx.State.Timeout(tx);
             goto Label_0097;
         }
     }
     Bucket bucket = new Bucket(this.owningSet) {
         nextBucketWeak = new WeakReference(this)
     };
     if (Interlocked.CompareExchange<Bucket>(ref this.owningSet.headBucket, bucket, this) == this)
     {
         this.previous = bucket;
     }
     return false;
 Label_0097:
     return true;
 }
 internal override void BeginCommit(InternalTransaction tx, bool asyncCommit, AsyncCallback asyncCallback, object asyncState)
 {
     tx.asyncCommit = asyncCommit;
     tx.asyncCallback = asyncCallback;
     tx.asyncState = asyncState;
     TransactionState._TransactionStateDelegatedCommitting.EnterState(tx);
 }
 internal int Add(InternalTransaction txNew)
 {
     Thread.BeginCriticalRegion();
     int num = 0;
     try
     {
         num = this.rwLock.AcquireReaderLock();
         try
         {
             if ((txNew.AbsoluteTimeout != 0x7fffffffffffffffL) && !this.timerEnabled)
             {
                 if (!this.timer.Change(this.timerInterval, this.timerInterval))
                 {
                     throw TransactionException.CreateInvalidOperationException(System.Transactions.SR.GetString("TraceSourceLtm"), System.Transactions.SR.GetString("UnexpectedTimerFailure"), null);
                 }
                 this.lastTimerTime = DateTime.UtcNow.Ticks;
                 this.timerEnabled = true;
             }
             txNew.CreationTime = this.CurrentTime;
             this.AddIter(txNew);
         }
         finally
         {
             this.rwLock.ReleaseReaderLock();
         }
     }
     finally
     {
         Thread.EndCriticalRegion();
     }
     return num;
 }
 internal override void EnterState(InternalTransaction tx)
 {
     base.CommonEnterState(tx);
     tx.committableTransaction.complete = true;
     if (tx.phase1Volatiles.dependentClones != 0)
     {
         TransactionState._TransactionStateAborted.EnterState(tx);
     }
     else if (((tx.phase1Volatiles.volatileEnlistmentCount == 1) && (tx.durableEnlistment == null)) && (tx.phase1Volatiles.volatileEnlistments[0].SinglePhaseNotification != null))
     {
         TransactionState._TransactionStateVolatileSPC.EnterState(tx);
     }
     else if (tx.phase1Volatiles.volatileEnlistmentCount > 0)
     {
         for (int i = 0; i < tx.phase1Volatiles.volatileEnlistmentCount; i++)
         {
             tx.phase1Volatiles.volatileEnlistments[i].twoPhaseState.ChangeStatePreparing(tx.phase1Volatiles.volatileEnlistments[i]);
             if (!tx.State.ContinuePhase1Prepares())
             {
                 return;
             }
         }
     }
     else
     {
         TransactionState._TransactionStateSPC.EnterState(tx);
     }
 }
 internal InternalEnlistment(System.Transactions.Enlistment enlistment, IEnlistmentNotification twoPhaseNotifications, InternalTransaction transaction, System.Transactions.Transaction atomicTransaction)
 {
     this.enlistment = enlistment;
     this.twoPhaseNotifications = twoPhaseNotifications;
     this.transaction = transaction;
     this.atomicTransaction = atomicTransaction;
 }
 internal override void EnterState(InternalTransaction tx)
 {
     base.EnterState(tx);
     base.CommonEnterState(tx);
     for (int i = 0; i < tx.phase0Volatiles.volatileEnlistmentCount; i++)
     {
         tx.phase0Volatiles.volatileEnlistments[i].twoPhaseState.InternalAborted(tx.phase0Volatiles.volatileEnlistments[i]);
     }
     for (int j = 0; j < tx.phase1Volatiles.volatileEnlistmentCount; j++)
     {
         tx.phase1Volatiles.volatileEnlistments[j].twoPhaseState.InternalAborted(tx.phase1Volatiles.volatileEnlistments[j]);
     }
     if (tx.durableEnlistment != null)
     {
         tx.durableEnlistment.State.InternalAborted(tx.durableEnlistment);
     }
     TransactionManager.TransactionTable.Remove(tx);
     if (DiagnosticTrace.Warning)
     {
         TransactionAbortedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), tx.TransactionTraceId);
     }
     tx.FireCompletion();
     if (tx.asyncCommit)
     {
         tx.SignalAsyncCompletion();
     }
 }
 internal override void EnterState(InternalTransaction tx)
 {
     base.CommonEnterState(tx);
     if (tx.committableTransaction != null)
     {
         tx.committableTransaction.complete = true;
     }
     if (tx.phase1Volatiles.dependentClones != 0)
     {
         tx.State.ChangeStateTransactionAborted(tx, null);
     }
     else
     {
         int volatileEnlistmentCount = tx.phase1Volatiles.volatileEnlistmentCount;
         if (tx.phase1Volatiles.preparedVolatileEnlistments < volatileEnlistmentCount)
         {
             for (int i = 0; i < volatileEnlistmentCount; i++)
             {
                 tx.phase1Volatiles.volatileEnlistments[i].twoPhaseState.ChangeStatePreparing(tx.phase1Volatiles.volatileEnlistments[i]);
                 if (!tx.State.ContinuePhase1Prepares())
                 {
                     return;
                 }
             }
         }
         else
         {
             this.Phase1VolatilePrepareDone(tx);
         }
     }
 }
 protected override void PromotedTransactionOutcome(InternalTransaction tx)
 {
     if ((tx.innerException == null) && (tx.PromotedTransaction != null))
     {
         tx.innerException = tx.PromotedTransaction.InnerException;
     }
     throw TransactionInDoubtException.Create(System.Transactions.SR.GetString("TraceSourceBase"), tx.innerException);
 }
 internal virtual void ChangeStatePromotedAborted(InternalTransaction tx)
 {
     if (DiagnosticTrace.Error)
     {
         InvalidOperationExceptionTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "");
     }
     throw new InvalidOperationException();
 }
 internal override void CompleteBlockingClone(InternalTransaction tx)
 {
     tx.phase0Volatiles.dependentClones--;
     if (tx.phase0Volatiles.preparedVolatileEnlistments == (tx.phase0VolatileWaveCount + tx.phase0Volatiles.dependentClones))
     {
         tx.State.Phase0VolatilePrepareDone(tx);
     }
 }
 internal override void Rollback(InternalTransaction tx, Exception e)
 {
     if (tx.innerException == null)
     {
         tx.innerException = e;
     }
     TransactionState._TransactionStateDelegatedAborting.EnterState(tx);
 }
 protected InternalEnlistment(System.Transactions.Enlistment enlistment, InternalTransaction transaction, System.Transactions.Transaction atomicTransaction)
 {
     this.enlistment = enlistment;
     this.transaction = transaction;
     this.atomicTransaction = atomicTransaction;
     this.enlistmentId = transaction.enlistmentCount++;
     this.traceIdentifier = EnlistmentTraceIdentifier.Empty;
 }
 internal override void ChangeStateTransactionAborted(InternalTransaction tx, Exception e)
 {
     if (tx.innerException == null)
     {
         tx.innerException = e;
     }
     TransactionState._TransactionStatePromotedP1Aborting.EnterState(tx);
 }
 internal override void Rollback(InternalTransaction tx, Exception e)
 {
     if (tx.innerException == null)
     {
         tx.innerException = e;
     }
     ((ISimpleTransactionSuperior) tx.promoter).Rollback();
     TransactionState._TransactionStateAborted.EnterState(tx);
 }
Exemple #19
0
 internal override void CompleteAbortingClone(InternalTransaction tx)
 {
     // A blocking clone simulates a phase 1 volatile
     //
     // Unlike a blocking clone however the aborting clones need to be accounted
     // for specifically.  So when one is complete remove it from the list.
     tx._phase1Volatiles._dependentClones--;
     Debug.Assert(tx._phase1Volatiles._dependentClones >= 0);
 }
 internal override void Rollback(InternalTransaction tx, Exception e)
 {
     if (tx.innerException == null)
     {
         tx.innerException = e;
     }
     tx.PromotedTransaction.Rollback();
     TransactionState._TransactionStatePromotedAborted.EnterState(tx);
 }
 internal override void Timeout(InternalTransaction tx)
 {
     if (DiagnosticTrace.Warning)
     {
         TransactionTimeoutTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), tx.TransactionTraceId);
     }
     TimeoutException e = new TimeoutException(System.Transactions.SR.GetString("TraceTransactionTimeout"));
     this.Rollback(tx, e);
 }
Exemple #22
0
 internal PromotableInternalEnlistment(
     Enlistment enlistment,
     InternalTransaction transaction,
     IPromotableSinglePhaseNotification promotableSinglePhaseNotification,
     Transaction atomicTransaction
     ) :
     base(enlistment, transaction, atomicTransaction)
 {
     this.promotableNotificationInterface = promotableSinglePhaseNotification;
 }
Exemple #23
0
 public Phase1VolatileEnlistment(
     Enlistment enlistment,
     InternalTransaction transaction,
     IEnlistmentNotification twoPhaseNotifications,
     ISinglePhaseNotification singlePhaseNotifications,
     Transaction atomicTransaction
     )
     : base(enlistment, transaction, twoPhaseNotifications, singlePhaseNotifications, atomicTransaction)
 {
 }
Exemple #24
0
 internal virtual bool PromoteDurable(InternalTransaction tx)
 {
     if (tx.durableEnlistment != null)
     {
         InternalEnlistment  durableEnlistment  = tx.durableEnlistment;
         IPromotedEnlistment promotedEnlistment = tx.PromotedTransaction.EnlistDurable(durableEnlistment.ResourceManagerIdentifier, (DurableInternalEnlistment)durableEnlistment, durableEnlistment.SinglePhaseNotification != null, EnlistmentOptions.None);
         tx.durableEnlistment.State.ChangeStatePromoted(tx.durableEnlistment, promotedEnlistment);
     }
     return(true);
 }
        private static void SignalCallback(object state)
        {
            InternalTransaction tx = (InternalTransaction)state;

            lock (tx)
            {
                tx.SignalAsyncCompletion();
                TransactionManager.TransactionTable.Remove(tx);
            }
        }
Exemple #26
0
 internal InternalEnlistment(System.Transactions.Enlistment enlistment, InternalTransaction transaction, IEnlistmentNotification twoPhaseNotifications, ISinglePhaseNotification singlePhaseNotifications, System.Transactions.Transaction atomicTransaction)
 {
     this.enlistment               = enlistment;
     this.transaction              = transaction;
     this.twoPhaseNotifications    = twoPhaseNotifications;
     this.singlePhaseNotifications = singlePhaseNotifications;
     this.atomicTransaction        = atomicTransaction;
     this.enlistmentId             = transaction.enlistmentCount++;
     this.traceIdentifier          = EnlistmentTraceIdentifier.Empty;
 }
        internal override void Timeout(InternalTransaction tx)
        {
            if (DiagnosticTrace.Warning)
            {
                TransactionTimeoutTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), tx.TransactionTraceId);
            }
            TimeoutException e = new TimeoutException(System.Transactions.SR.GetString("TraceTransactionTimeout"));

            this.Rollback(tx, e);
        }
 internal InternalEnlistment(System.Transactions.Enlistment enlistment, InternalTransaction transaction, IEnlistmentNotification twoPhaseNotifications, ISinglePhaseNotification singlePhaseNotifications, System.Transactions.Transaction atomicTransaction)
 {
     this.enlistment = enlistment;
     this.transaction = transaction;
     this.twoPhaseNotifications = twoPhaseNotifications;
     this.singlePhaseNotifications = singlePhaseNotifications;
     this.atomicTransaction = atomicTransaction;
     this.enlistmentId = transaction.enlistmentCount++;
     this.traceIdentifier = EnlistmentTraceIdentifier.Empty;
 }
 internal override void AddOutcomeRegistrant(InternalTransaction tx, TransactionCompletedEventHandler transactionCompletedDelegate)
 {
     if (transactionCompletedDelegate != null)
     {
         TransactionEventArgs e = new TransactionEventArgs {
             transaction = tx.outcomeSource.InternalClone()
         };
         transactionCompletedDelegate(e.transaction, e);
     }
 }
 internal override void AddOutcomeRegistrant(InternalTransaction tx, TransactionCompletedEventHandler transactionCompletedDelegate)
 {
     if (transactionCompletedDelegate != null)
     {
         TransactionEventArgs e = new TransactionEventArgs {
             transaction = tx.outcomeSource.InternalClone()
         };
         transactionCompletedDelegate(e.transaction, e);
     }
 }
 private void AddIter(InternalTransaction txNew)
 {
     BucketSet headBucketSet = this.headBucketSet;
     while (headBucketSet.AbsoluteTimeout != txNew.AbsoluteTimeout)
     {
         BucketSet set3 = null;
         do
         {
             WeakReference nextSetWeak = (WeakReference) headBucketSet.nextSetWeak;
             BucketSet target = null;
             if (nextSetWeak != null)
             {
                 target = (BucketSet) nextSetWeak.Target;
             }
             if (target == null)
             {
                 BucketSet set6 = new BucketSet(this, txNew.AbsoluteTimeout);
                 WeakReference reference5 = new WeakReference(set6);
                 WeakReference reference4 = (WeakReference) Interlocked.CompareExchange(ref headBucketSet.nextSetWeak, reference5, nextSetWeak);
                 if (reference4 == nextSetWeak)
                 {
                     set6.prevSet = headBucketSet;
                 }
             }
             else
             {
                 set3 = headBucketSet;
                 headBucketSet = target;
             }
         }
         while (headBucketSet.AbsoluteTimeout > txNew.AbsoluteTimeout);
         if (headBucketSet.AbsoluteTimeout != txNew.AbsoluteTimeout)
         {
             BucketSet set2 = new BucketSet(this, txNew.AbsoluteTimeout);
             WeakReference reference3 = new WeakReference(set2);
             set2.nextSetWeak = set3.nextSetWeak;
             WeakReference reference2 = (WeakReference) Interlocked.CompareExchange(ref set3.nextSetWeak, reference3, set2.nextSetWeak);
             if (reference2 == set2.nextSetWeak)
             {
                 if (reference2 != null)
                 {
                     BucketSet set5 = (BucketSet) reference2.Target;
                     if (set5 != null)
                     {
                         set5.prevSet = set2;
                     }
                 }
                 set2.prevSet = headBucketSet;
             }
             headBucketSet = set3;
             set3 = null;
         }
     }
     headBucketSet.Add(txNew);
 }
Exemple #32
0
        private void AddIter(InternalTransaction txNew)
        {
            BucketSet headBucketSet = this.headBucketSet;

            while (headBucketSet.AbsoluteTimeout != txNew.AbsoluteTimeout)
            {
                BucketSet set3 = null;
                do
                {
                    WeakReference nextSetWeak = (WeakReference)headBucketSet.nextSetWeak;
                    BucketSet     target      = null;
                    if (nextSetWeak != null)
                    {
                        target = (BucketSet)nextSetWeak.Target;
                    }
                    if (target == null)
                    {
                        BucketSet     set6       = new BucketSet(this, txNew.AbsoluteTimeout);
                        WeakReference reference5 = new WeakReference(set6);
                        WeakReference reference4 = (WeakReference)Interlocked.CompareExchange(ref headBucketSet.nextSetWeak, reference5, nextSetWeak);
                        if (reference4 == nextSetWeak)
                        {
                            set6.prevSet = headBucketSet;
                        }
                    }
                    else
                    {
                        set3          = headBucketSet;
                        headBucketSet = target;
                    }
                }while (headBucketSet.AbsoluteTimeout > txNew.AbsoluteTimeout);
                if (headBucketSet.AbsoluteTimeout != txNew.AbsoluteTimeout)
                {
                    BucketSet     set2       = new BucketSet(this, txNew.AbsoluteTimeout);
                    WeakReference reference3 = new WeakReference(set2);
                    set2.nextSetWeak = set3.nextSetWeak;
                    WeakReference reference2 = (WeakReference)Interlocked.CompareExchange(ref set3.nextSetWeak, reference3, set2.nextSetWeak);
                    if (reference2 == set2.nextSetWeak)
                    {
                        if (reference2 != null)
                        {
                            BucketSet set5 = (BucketSet)reference2.Target;
                            if (set5 != null)
                            {
                                set5.prevSet = set2;
                            }
                        }
                        set2.prevSet = headBucketSet;
                    }
                    headBucketSet = set3;
                    set3          = null;
                }
            }
            headBucketSet.Add(txNew);
        }
Exemple #33
0
 internal InternalEnlistment(
     Enlistment enlistment,
     IEnlistmentNotification twoPhaseNotifications,
     InternalTransaction transaction,
     Transaction atomicTransaction)
 {
     _enlistment            = enlistment;
     _twoPhaseNotifications = twoPhaseNotifications;
     _transaction           = transaction;
     _atomicTransaction     = atomicTransaction;
 }
 internal Enlistment(InternalTransaction transaction, IEnlistmentNotification twoPhaseNotifications, ISinglePhaseNotification singlePhaseNotifications, Transaction atomicTransaction, EnlistmentOptions enlistmentOptions)
 {
     if ((enlistmentOptions & EnlistmentOptions.EnlistDuringPrepareRequired) != EnlistmentOptions.None)
     {
         this.internalEnlistment = new System.Transactions.InternalEnlistment(this, transaction, twoPhaseNotifications, singlePhaseNotifications, atomicTransaction);
     }
     else
     {
         this.internalEnlistment = new Phase1VolatileEnlistment(this, transaction, twoPhaseNotifications, singlePhaseNotifications, atomicTransaction);
     }
 }
Exemple #35
0
        internal override void GetObjectData(InternalTransaction tx, SerializationInfo serializationInfo, StreamingContext context)
        {
            ISerializable promotedTransaction = tx.PromotedTransaction;

            if (promotedTransaction == null)
            {
                throw new NotSupportedException();
            }
            serializationInfo.FullTypeName = tx.PromotedTransaction.GetType().FullName;
            promotedTransaction.GetObjectData(serializationInfo, context);
        }
 internal Enlistment(InternalTransaction transaction, IEnlistmentNotification twoPhaseNotifications, ISinglePhaseNotification singlePhaseNotifications, Transaction atomicTransaction, EnlistmentOptions enlistmentOptions)
 {
     if ((enlistmentOptions & EnlistmentOptions.EnlistDuringPrepareRequired) != EnlistmentOptions.None)
     {
         this.internalEnlistment = new System.Transactions.InternalEnlistment(this, transaction, twoPhaseNotifications, singlePhaseNotifications, atomicTransaction);
     }
     else
     {
         this.internalEnlistment = new Phase1VolatileEnlistment(this, transaction, twoPhaseNotifications, singlePhaseNotifications, atomicTransaction);
     }
 }
Exemple #37
0
 internal DurableInternalEnlistment(
     Enlistment enlistment,
     Guid resourceManagerIdentifier,
     InternalTransaction transaction,
     IEnlistmentNotification twoPhaseNotifications,
     ISinglePhaseNotification singlePhaseNotifications,
     Transaction atomicTransaction) :
     base(enlistment, transaction, twoPhaseNotifications, singlePhaseNotifications, atomicTransaction)
 {
     _resourceManagerIdentifier = resourceManagerIdentifier;
 }
 internal override void Phase0VolatilePrepareDone(InternalTransaction tx)
 {
     Monitor.Exit(tx);
     try
     {
         tx.phase0Volatiles.VolatileDemux.oletxEnlistment.Prepared();
     }
     finally
     {
         Monitor.Enter(tx);
     }
 }
 internal override void EnterState(InternalTransaction tx)
 {
     base.CommonEnterState(tx);
     if (tx.durableEnlistment != null)
     {
         tx.durableEnlistment.State.ChangeStateCommitting(tx.durableEnlistment);
     }
     else
     {
         TransactionState._TransactionStateCommitted.EnterState(tx);
     }
 }
 internal void PSPEInitialize(InternalTransaction tx, IPromotableSinglePhaseNotification promotableSinglePhaseNotification)
 {
     base.CommonEnterState(tx);
     try
     {
         promotableSinglePhaseNotification.Initialize();
     }
     finally
     {
         TransactionState._TransactionStateActive.CommonEnterState(tx);
     }
 }
Exemple #41
0
 internal void PSPEInitialize(InternalTransaction tx, IPromotableSinglePhaseNotification promotableSinglePhaseNotification)
 {
     base.CommonEnterState(tx);
     try
     {
         promotableSinglePhaseNotification.Initialize();
     }
     finally
     {
         TransactionState._TransactionStateActive.CommonEnterState(tx);
     }
 }
Exemple #42
0
 internal InternalEnlistment(
     Enlistment enlistment,
     IEnlistmentNotification twoPhaseNotifications,
     InternalTransaction transaction,
     Transaction atomicTransaction
     )
 {
     this.enlistment            = enlistment;
     this.twoPhaseNotifications = twoPhaseNotifications;
     this.transaction           = transaction;
     this.atomicTransaction     = atomicTransaction;
 }
 internal override void Phase1VolatilePrepareDone(InternalTransaction tx)
 {
     Monitor.Exit(tx);
     try
     {
         tx.phase1Volatiles.VolatileDemux.oletxEnlistment.Prepared();
     }
     finally
     {
         Monitor.Enter(tx);
     }
 }
Exemple #44
0
 internal Enlistment(
     IEnlistmentNotification twoPhaseNotifications,
     InternalTransaction transaction,
     Transaction atomicTransaction)
 {
     _internalEnlistment = new InternalEnlistment(
         this,
         twoPhaseNotifications,
         transaction,
         atomicTransaction
         );
 }
Exemple #45
0
        internal static void DistributedTransactionOutcome(InternalTransaction tx, TransactionStatus status)
        {
            FinalizedObject?fo = null;

            lock (tx)
            {
                if (null == tx._innerException)
                {
                    Debug.Assert(tx.PromotedTransaction != null);
                    tx._innerException = tx.PromotedTransaction.InnerException;
                }

                Debug.Assert(tx.State ! != null);
                switch (status)
                {
                case TransactionStatus.Committed:
                {
                    tx.State.ChangeStatePromotedCommitted(tx);
                    break;
                }

                case TransactionStatus.Aborted:
                {
                    tx.State.ChangeStatePromotedAborted(tx);
                    break;
                }

                case TransactionStatus.InDoubt:
                {
                    tx.State.InDoubtFromDtc(tx);
                    break;
                }

                default:
                {
                    Debug.Fail("InternalTransaction.DistributedTransactionOutcome - Unexpected TransactionStatus");
                    TransactionException.CreateInvalidOperationException(TraceSourceType.TraceSourceLtm,
                                                                         "",
                                                                         null,
                                                                         tx.DistributedTxId
                                                                         );
                    break;
                }
                }

                fo = tx._finalizedObject;
            }

            if (null != fo)
            {
                fo.Dispose();
            }
        }
Exemple #46
0
 // This constructor is for a promotable single phase enlistment.
 internal Enlistment(
     InternalTransaction transaction,
     IPromotableSinglePhaseNotification promotableSinglePhaseNotification,
     Transaction atomicTransaction)
 {
     _internalEnlistment = new PromotableInternalEnlistment(
         this,
         transaction,
         promotableSinglePhaseNotification,
         atomicTransaction
         );
 }
Exemple #47
0
 // For Promotable Enlistments
 protected InternalEnlistment(
     Enlistment enlistment,
     InternalTransaction transaction,
     Transaction atomicTransaction
     )
 {
     Debug.Assert(this is PromotableInternalEnlistment, "this is PromotableInternalEnlistment");
     this.enlistment        = enlistment;
     this.transaction       = transaction;
     this.atomicTransaction = atomicTransaction;
     this.enlistmentId      = transaction.enlistmentCount++;
     this.traceIdentifier   = EnlistmentTraceIdentifier.Empty;
 }
 internal override void EnterState(InternalTransaction tx)
 {
     base.CommonEnterState(tx);
     this.ChangeStatePromotedAborted(tx);
     Monitor.Exit(tx);
     try
     {
         tx.phase1Volatiles.VolatileDemux.oletxEnlistment.ForceRollback();
     }
     finally
     {
         Monitor.Enter(tx);
     }
 }
        internal CommittableTransaction(IsolationLevel isoLevel, TimeSpan timeout) : base(isoLevel, (InternalTransaction)null)
        {
            // object to use for synchronization rather than locking on a public object
            _internalTransaction = new InternalTransaction(timeout, this);

            // Because we passed null for the internal transaction to the base class, we need to
            // fill in the traceIdentifier field here.
            _internalTransaction._cloneCount = 1;
            _cloneId = 1;
            if (DiagnosticTrace.Information)
            {
                TransactionCreatedTraceRecord.Trace(SR.TraceSourceLtm, TransactionTraceId);
            }
        }
 internal Transaction(System.Transactions.IsolationLevel isoLevel, InternalTransaction internalTransaction)
 {
     TransactionManager.ValidateIsolationLevel(isoLevel);
     this.isoLevel = isoLevel;
     if (System.Transactions.IsolationLevel.Unspecified == this.isoLevel)
     {
         this.isoLevel = TransactionManager.DefaultIsolationLevel;
     }
     if (internalTransaction != null)
     {
         this.internalTransaction = internalTransaction;
         this.cloneId = Interlocked.Increment(ref this.internalTransaction.cloneCount);
     }
 }
 internal Transaction(System.Transactions.IsolationLevel isoLevel, InternalTransaction internalTransaction)
 {
     TransactionManager.ValidateIsolationLevel(isoLevel);
     this.isoLevel = isoLevel;
     if (System.Transactions.IsolationLevel.Unspecified == this.isoLevel)
     {
         this.isoLevel = TransactionManager.DefaultIsolationLevel;
     }
     if (internalTransaction != null)
     {
         this.internalTransaction = internalTransaction;
         this.cloneId             = Interlocked.Increment(ref this.internalTransaction.cloneCount);
     }
 }
Exemple #52
0
        internal override void EnterState(InternalTransaction tx)
        {
            if (tx.outcomeSource.isoLevel == IsolationLevel.Snapshot)
            {
                throw TransactionException.CreateInvalidOperationException(System.Transactions.SR.GetString("TraceSourceLtm"), System.Transactions.SR.GetString("CannotPromoteSnapshot"), null);
            }
            base.CommonEnterState(tx);
            OletxTransaction transaction = null;

            try
            {
                if (DiagnosticTrace.Verbose && (tx.durableEnlistment != null))
                {
                    EnlistmentNotificationCallTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), tx.durableEnlistment.EnlistmentTraceId, NotificationCall.Promote);
                }
                transaction = TransactionState._TransactionStatePSPEOperation.PSPEPromote(tx);
            }
            catch (TransactionPromotionException exception)
            {
                tx.innerException = exception;
                if (DiagnosticTrace.Verbose)
                {
                    ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), exception);
                }
            }
            finally
            {
                if (transaction == null)
                {
                    tx.State.ChangeStateAbortedDuringPromotion(tx);
                }
            }
            if (transaction != null)
            {
                tx.PromotedTransaction = transaction;
                Hashtable promotedTransactionTable = TransactionManager.PromotedTransactionTable;
                lock (promotedTransactionTable)
                {
                    tx.finalizedObject = new FinalizedObject(tx, tx.PromotedTransaction.Identifier);
                    WeakReference reference = new WeakReference(tx.outcomeSource, false);
                    promotedTransactionTable[tx.PromotedTransaction.Identifier] = reference;
                }
                TransactionManager.FireDistributedTransactionStarted(tx.outcomeSource);
                if (DiagnosticTrace.Information)
                {
                    TransactionPromotedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), tx.TransactionTraceId, transaction.TransactionTraceId);
                }
                this.PromoteEnlistmentsAndOutcome(tx);
            }
        }
        internal static void DistributedTransactionOutcome(InternalTransaction tx, TransactionStatus status)
        {
            FinalizedObject fo = null;

            lock ( tx )
            {
                if (null == tx.innerException)
                {
                    tx.innerException = tx.PromotedTransaction.InnerException;
                }

                switch (status)
                {
                case TransactionStatus.Committed:
                {
                    tx.State.ChangeStatePromotedCommitted(tx);
                    break;
                }

                case TransactionStatus.Aborted:
                {
                    tx.State.ChangeStatePromotedAborted(tx);
                    break;
                }

                case TransactionStatus.InDoubt:
                {
                    tx.State.InDoubtFromDtc(tx);
                    break;
                }

                default:
                {
                    Debug.Assert(false, "InternalTransaction.DistributedTransactionOutcome - Unexpected TransactionStatus");
                    TransactionException.CreateInvalidOperationException(SR.GetString(SR.TraceSourceLtm),
                                                                         "",
                                                                         null
                                                                         );
                    break;
                }
                }

                fo = tx.finalizedObject;
            }

            if (null != fo)
            {
                fo.Dispose();
            }
        }
 internal Transaction(System.Transactions.IsolationLevel isoLevel, ISimpleTransactionSuperior superior)
 {
     TransactionManager.ValidateIsolationLevel(isoLevel);
     if (superior == null)
     {
         throw new ArgumentNullException("superior");
     }
     this.isoLevel = isoLevel;
     if (System.Transactions.IsolationLevel.Unspecified == this.isoLevel)
     {
         this.isoLevel = TransactionManager.DefaultIsolationLevel;
     }
     this.internalTransaction = new InternalTransaction(this, superior);
     this.cloneId             = 1;
 }
Exemple #55
0
 internal override void CreateAbortingClone(InternalTransaction tx)
 {
     if (tx.phase1Volatiles.VolatileDemux != null)
     {
         tx.phase1Volatiles.dependentClones++;
     }
     else
     {
         if (tx.abortingDependentClone == null)
         {
             tx.abortingDependentClone = tx.PromotedTransaction.DependentClone(false);
         }
         tx.abortingDependentCloneCount++;
     }
 }
 internal DependentTransaction(IsolationLevel isoLevel, InternalTransaction internalTransaction, bool blocking) : base(isoLevel, internalTransaction)
 {
     this.blocking = blocking;
     lock (base.internalTransaction)
     {
         if (blocking)
         {
             base.internalTransaction.State.CreateBlockingClone(base.internalTransaction);
         }
         else
         {
             base.internalTransaction.State.CreateAbortingClone(base.internalTransaction);
         }
     }
 }
Exemple #57
0
 internal InternalEnlistment(
     Enlistment enlistment,
     InternalTransaction transaction,
     IEnlistmentNotification twoPhaseNotifications,
     ISinglePhaseNotification singlePhaseNotifications,
     Transaction atomicTransaction)
 {
     _enlistment               = enlistment;
     _transaction              = transaction;
     _twoPhaseNotifications    = twoPhaseNotifications;
     _singlePhaseNotifications = singlePhaseNotifications;
     _atomicTransaction        = atomicTransaction;
     _enlistmentId             = transaction._enlistmentCount++;
     _traceIdentifier          = EnlistmentTraceIdentifier.Empty;
 }
Exemple #58
0
 internal Enlistment(
     Guid resourceManagerIdentifier,
     InternalTransaction transaction,
     IEnlistmentNotification twoPhaseNotifications,
     ISinglePhaseNotification singlePhaseNotifications,
     Transaction atomicTransaction)
 {
     _internalEnlistment = new DurableInternalEnlistment(
         this,
         resourceManagerIdentifier,
         transaction,
         twoPhaseNotifications,
         singlePhaseNotifications,
         atomicTransaction
         );
 }