Exemplo n.º 1
0
 internal override void InternalDispose()
 {
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "IDisposable.Dispose");
     }
     if (Interlocked.Exchange(ref this.disposed, 1) != 1)
     {
         if (base.internalTransaction.State.get_Status(base.internalTransaction) == TransactionStatus.Active)
         {
             lock (base.internalTransaction)
             {
                 base.internalTransaction.State.DisposeRoot(base.internalTransaction);
             }
         }
         long num = Interlocked.Decrement(ref base.internalTransaction.cloneCount);
         if (num == 0L)
         {
             base.internalTransaction.Dispose();
         }
         if (DiagnosticTrace.Verbose)
         {
             MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "IDisposable.Dispose");
         }
     }
 }
        internal OletxDependentTransaction DependentClone(bool delayCommit)
        {
            OletxDependentTransaction transaction = null;

            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxTransaction.DependentClone");
            }
            if (TransactionStatus.Aborted == this.Status)
            {
                throw TransactionAbortedException.Create(System.Transactions.SR.GetString("TraceSourceOletx"), this.realOletxTransaction.innerException);
            }
            if (TransactionStatus.InDoubt == this.Status)
            {
                throw TransactionInDoubtException.Create(System.Transactions.SR.GetString("TraceSourceOletx"), this.realOletxTransaction.innerException);
            }
            if (this.Status != TransactionStatus.Active)
            {
                throw TransactionException.Create(System.Transactions.SR.GetString("TraceSourceOletx"), System.Transactions.SR.GetString("TransactionAlreadyOver"), null);
            }
            transaction = new OletxDependentTransaction(this.realOletxTransaction, delayCommit);
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxTransaction.DependentClone");
            }
            return(transaction);
        }
Exemplo n.º 3
0
        public void EndCommit(IAsyncResult asyncResult)
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceLtm, "CommittableTransaction.EndCommit");
            }

            if (asyncResult != ((object)this))
            {
                throw new ArgumentException(SR.BadAsyncResult, nameof(asyncResult));
            }

            lock (_internalTransaction)
            {
                do
                {
                    if (_internalTransaction.State.IsCompleted(_internalTransaction))
                    {
                        break;
                    }
                } while (Monitor.Wait(_internalTransaction));

                _internalTransaction.State.EndCommit(_internalTransaction);
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.TraceSourceLtm, "CommittableTransaction.EndCommit");
            }
        }
Exemplo n.º 4
0
        public static byte[] GetTransmitterPropagationToken(
            Transaction transaction
            )
        {
            if (!TransactionManager._platformValidated)
            {
                TransactionManager.ValidatePlatform();
            }

            if (null == transaction)
            {
                throw new ArgumentNullException("transaction");
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx),
                                               "TransactionInterop.GetTransmitterPropagationToken"
                                               );
            }

            // First, make sure we are working with an OletxTransaction.
            OletxTransaction oletxTx = TransactionInterop.ConvertToOletxTransaction(transaction);

            byte[] token = GetTransmitterPropagationToken(oletxTx);

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx),
                                              "TransactionInterop.GetTransmitterPropagationToken"
                                              );
            }

            return(token);
        }
Exemplo n.º 5
0
        internal override void DependentCloneCompleted()
        {
            bool flag = false;

            lock (this)
            {
                if (DiagnosticTrace.Verbose)
                {
                    string methodName = "OletxPhase0VolatileEnlistmentContainer.DependentCloneCompleted, outstandingNotifications = " + this.outstandingNotifications.ToString(CultureInfo.CurrentCulture) + ", incompleteDependentClones = " + this.incompleteDependentClones.ToString(CultureInfo.CurrentCulture) + ", phase = " + this.phase.ToString(CultureInfo.CurrentCulture);
                    MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), methodName);
                }
                base.incompleteDependentClones--;
                if ((base.incompleteDependentClones == 0) && (base.phase == 0))
                {
                    base.outstandingNotifications++;
                    flag = true;
                }
            }
            if (flag)
            {
                this.DecrementOutstandingNotifications(true);
            }
            if (DiagnosticTrace.Verbose)
            {
                string str = "OletxPhase0VolatileEnlistmentContainer.DependentCloneCompleted";
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), str);
            }
        }
        public bool EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification promotableSinglePhaseNotification)
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "Transaction.EnlistPromotableSinglePhase");
            }
            if (this.Disposed)
            {
                throw new ObjectDisposedException("Transaction");
            }
            if (promotableSinglePhaseNotification == null)
            {
                throw new ArgumentNullException("promotableSinglePhaseNotification");
            }
            if (this.complete)
            {
                throw TransactionException.CreateTransactionCompletedException(System.Transactions.SR.GetString("TraceSourceLtm"));
            }
            bool flag = false;

            lock (this.internalTransaction)
            {
                flag = this.internalTransaction.State.EnlistPromotableSinglePhase(this.internalTransaction, promotableSinglePhaseNotification, this);
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "Transaction.EnlistPromotableSinglePhase");
            }
            return(flag);
        }
 void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext context)
 {
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "ISerializable.GetObjectData");
     }
     if (this.Disposed)
     {
         throw new ObjectDisposedException("Transaction");
     }
     if (serializationInfo == null)
     {
         throw new ArgumentNullException("serializationInfo");
     }
     if (this.complete)
     {
         throw TransactionException.CreateTransactionCompletedException(System.Transactions.SR.GetString("TraceSourceLtm"));
     }
     lock (this.internalTransaction)
     {
         this.internalTransaction.State.GetObjectData(this.internalTransaction, serializationInfo, context);
     }
     if (DiagnosticTrace.Information)
     {
         TransactionSerializedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), this.TransactionTraceId);
     }
     if (DiagnosticTrace.Verbose)
     {
         MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "ISerializable.GetObjectData");
     }
 }
Exemplo n.º 8
0
        public void Rollback(Exception e)
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceLtm, "Transaction.Rollback");
            }

            if (DiagnosticTrace.Warning)
            {
                TransactionRollbackCalledTraceRecord.Trace(SR.TraceSourceLtm, TransactionTraceId);
            }

            if (Disposed)
            {
                throw new ObjectDisposedException(nameof(Transaction));
            }

            lock (_internalTransaction)
            {
                Debug.Assert(_internalTransaction.State != null);
                _internalTransaction.State.Rollback(_internalTransaction, e);
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.TraceSourceLtm, "Transaction.Rollback");
            }
        }
Exemplo n.º 9
0
        // Create a clone of the transaction that forwards requests to this object.
        //
        public Transaction Clone()
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceLtm, "Transaction.Clone");
            }

            if (Disposed)
            {
                throw new ObjectDisposedException(nameof(Transaction));
            }

            if (_complete)
            {
                throw TransactionException.CreateTransactionCompletedException(SR.TraceSourceLtm, DistributedTxId);
            }

            Transaction clone = InternalClone();

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.TraceSourceLtm, "Transaction.Clone");
            }
            return(clone);
        }
        internal void BeginCommit(
            InternalTransaction internalTransaction
            )
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx),
                                               "CommittableTransaction.BeginCommit"
                                               );
                TransactionCommitCalledTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx),
                                                         this.TransactionTraceId
                                                         );
            }

            Debug.Assert((0 == this.disposed), "OletxTransction object is disposed");
            this.realOletxTransaction.InternalTransaction = internalTransaction;

            this.commitCalled = true;

            this.realOletxTransaction.Commit();

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx),
                                              "CommittableTransaction.BeginCommit"
                                              );
            }

            return;
        }
Exemplo n.º 11
0
        internal void VoteRequest()
        {
            OletxVolatileEnlistment enlistment = null;
            int  count = 0;
            bool flag  = false;

            lock (this)
            {
                if (DiagnosticTrace.Verbose)
                {
                    string methodName = "OletxPhase1VolatileEnlistmentContainer.VoteRequest";
                    MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), methodName);
                }
                base.phase = 1;
                if (0 < base.incompleteDependentClones)
                {
                    flag = true;
                    base.outstandingNotifications = 1;
                }
                else
                {
                    base.outstandingNotifications = base.enlistmentList.Count;
                    count = base.enlistmentList.Count;
                    if (count == 0)
                    {
                        base.outstandingNotifications = 1;
                    }
                }
                base.realOletxTransaction.TooLateForEnlistments = true;
            }
            if (flag)
            {
                this.DecrementOutstandingNotifications(false);
            }
            else if (count == 0)
            {
                this.DecrementOutstandingNotifications(true);
            }
            else
            {
                for (int i = 0; i < count; i++)
                {
                    enlistment = base.enlistmentList[i] as OletxVolatileEnlistment;
                    if (enlistment == null)
                    {
                        if (DiagnosticTrace.Critical)
                        {
                            InternalErrorTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "");
                        }
                        throw new InvalidOperationException(System.Transactions.SR.GetString("InternalError"));
                    }
                    enlistment.Prepare(this);
                }
            }
            if (DiagnosticTrace.Verbose)
            {
                string str = "OletxPhase1VolatileEnlistmentContainer.VoteRequest";
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), str);
            }
        }
        public void Complete()
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx),
                                               "DependentTransaction.Complete"
                                               );
            }

            Debug.Assert((0 == this.disposed), "OletxTransction object is disposed");

            int localCompleted = Interlocked.CompareExchange(ref this.completed, 1, 0);

            if (1 == localCompleted)
            {
                throw TransactionException.CreateTransactionCompletedException(SR.GetString(SR.TraceSourceOletx));
            }

            if (DiagnosticTrace.Information)
            {
                DependentCloneCompleteTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx),
                                                        this.TransactionTraceId
                                                        );
            }

            this.volatileEnlistmentContainer.DependentCloneCompleted();

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx),
                                              "DependentTransaction.Complete"
                                              );
            }
        }
Exemplo n.º 13
0
 public void Commit()
 {
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "CommittableTransaction.Commit");
         TransactionCommitCalledTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), base.TransactionTraceId);
     }
     if (base.Disposed)
     {
         throw new ObjectDisposedException("Transaction");
     }
     lock (base.internalTransaction)
     {
         if (base.complete)
         {
             throw TransactionException.CreateTransactionCompletedException(System.Transactions.SR.GetString("TraceSourceLtm"));
         }
         base.internalTransaction.State.BeginCommit(base.internalTransaction, false, null, null);
         while (!base.internalTransaction.State.IsCompleted(base.internalTransaction) && Monitor.Wait(base.internalTransaction))
         {
         }
         base.internalTransaction.State.EndCommit(base.internalTransaction);
     }
     if (DiagnosticTrace.Verbose)
     {
         MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "CommittableTransaction.Commit");
     }
 }
Exemplo n.º 14
0
 public IAsyncResult BeginCommit(AsyncCallback asyncCallback, object asyncState)
 {
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "CommittableTransaction.BeginCommit");
         TransactionCommitCalledTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), base.TransactionTraceId);
     }
     if (base.Disposed)
     {
         throw new ObjectDisposedException("Transaction");
     }
     lock (base.internalTransaction)
     {
         if (base.complete)
         {
             throw TransactionException.CreateTransactionCompletedException(System.Transactions.SR.GetString("TraceSourceLtm"));
         }
         base.internalTransaction.State.BeginCommit(base.internalTransaction, true, asyncCallback, asyncState);
     }
     if (DiagnosticTrace.Verbose)
     {
         MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "CommittableTransaction.BeginCommit");
     }
     return(this);
 }
Exemplo n.º 15
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"
                                              );
            }
        }
Exemplo n.º 16
0
        // Handle Transaction Disposal.
        //
        internal virtual void InternalDispose()
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceLtm, "IDisposable.Dispose");
            }

            if (Interlocked.Exchange(ref _disposed, Transaction._disposedTrueValue) == Transaction._disposedTrueValue)
            {
                return;
            }

            // Attempt to clean up the internal transaction
            long remainingITx = Interlocked.Decrement(ref _internalTransaction._cloneCount);

            if (remainingITx == 0)
            {
                _internalTransaction.Dispose();
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.TraceSourceLtm, "IDisposable.Dispose");
            }
        }
        public DependentTransaction DependentClone(DependentCloneOption cloneOption)
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "Transaction.DependentClone");
            }
            if ((cloneOption != DependentCloneOption.BlockCommitUntilComplete) && (cloneOption != DependentCloneOption.RollbackIfNotComplete))
            {
                throw new ArgumentOutOfRangeException("cloneOption");
            }
            if (this.Disposed)
            {
                throw new ObjectDisposedException("Transaction");
            }
            if (this.complete)
            {
                throw TransactionException.CreateTransactionCompletedException(System.Transactions.SR.GetString("TraceSourceLtm"));
            }
            DependentTransaction transaction = new DependentTransaction(this.isoLevel, this.internalTransaction, cloneOption == DependentCloneOption.BlockCommitUntilComplete);

            if (DiagnosticTrace.Information)
            {
                DependentCloneCreatedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), transaction.TransactionTraceId, cloneOption);
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "Transaction.DependentClone");
            }
            return(transaction);
        }
Exemplo n.º 18
0
        public byte[] RecoveryInformation()
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                               "PreparingEnlistment.RecoveryInformation"
                                               );
            }

            try
            {
                lock (this.internalEnlistment.SyncRoot)
                {
                    return(this.internalEnlistment.State.RecoveryInformation(this.internalEnlistment));
                }
            }
            finally
            {
                if (DiagnosticTrace.Verbose)
                {
                    MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                                  "PreparingEnlistment.RecoveryInformation"
                                                  );
                }
            }
        }
 public Enlistment EnlistVolatile(ISinglePhaseNotification singlePhaseNotification, EnlistmentOptions enlistmentOptions)
 {
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "Transaction.EnlistVolatile( ISinglePhaseNotification )");
     }
     if (this.Disposed)
     {
         throw new ObjectDisposedException("Transaction");
     }
     if (singlePhaseNotification == null)
     {
         throw new ArgumentNullException("singlePhaseNotification");
     }
     if ((enlistmentOptions != EnlistmentOptions.None) && (enlistmentOptions != EnlistmentOptions.EnlistDuringPrepareRequired))
     {
         throw new ArgumentOutOfRangeException("enlistmentOptions");
     }
     if (this.complete)
     {
         throw TransactionException.CreateTransactionCompletedException(System.Transactions.SR.GetString("TraceSourceLtm"));
     }
     lock (this.internalTransaction)
     {
         Enlistment enlistment2 = this.internalTransaction.State.EnlistVolatile(this.internalTransaction, singlePhaseNotification, enlistmentOptions, this);
         if (DiagnosticTrace.Verbose)
         {
             MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), "Transaction.EnlistVolatile( ISinglePhaseNotification )");
         }
         return(enlistment2);
     }
 }
Exemplo n.º 20
0
        public void ForceRollback(Exception e)
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                               "PreparingEnlistment.ForceRollback"
                                               );
            }

            if (DiagnosticTrace.Warning)
            {
                EnlistmentCallbackNegativeTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                                            this.internalEnlistment.EnlistmentTraceId,
                                                            EnlistmentCallback.ForceRollback
                                                            );
            }

            lock (this.internalEnlistment.SyncRoot)
            {
                this.internalEnlistment.State.ForceRollback(this.internalEnlistment, e);
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                              "PreparingEnlistment.ForceRollback"
                                              );
            }
        }
Exemplo n.º 21
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"
                                              );
            }
        }
        internal static byte[] GetRecoveryInformation(string startupInfo, byte[] resourceManagerRecoveryInformation)
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), "TransactionManager.GetRecoveryInformation");
            }
            MemoryStream output = new MemoryStream();

            byte[] buffer = null;
            try
            {
                BinaryWriter writer = new BinaryWriter(output);
                writer.Write(1);
                if (startupInfo != null)
                {
                    writer.Write(startupInfo);
                }
                else
                {
                    writer.Write("");
                }
                writer.Write(resourceManagerRecoveryInformation);
                writer.Flush();
                buffer = output.ToArray();
            }
            finally
            {
                output.Close();
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), "TransactionManager.GetRecoveryInformation");
            }
            return(buffer);
        }
Exemplo n.º 23
0
        internal override void DecrementOutstandingNotifications(bool voteYes)
        {
            bool flag = false;
            IPhase0EnlistmentShim shim = null;

            lock (this)
            {
                if (DiagnosticTrace.Verbose)
                {
                    string methodName = "OletxPhase0VolatileEnlistmentContainer.DecrementOutstandingNotifications, outstandingNotifications = " + this.outstandingNotifications.ToString(CultureInfo.CurrentCulture) + ", incompleteDependentClones = " + this.incompleteDependentClones.ToString(CultureInfo.CurrentCulture);
                    MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), methodName);
                }
                base.outstandingNotifications--;
                base.collectedVoteYes = base.collectedVoteYes && voteYes;
                if ((base.outstandingNotifications == 0) && (base.incompleteDependentClones == 0))
                {
                    if ((base.phase == 0) && !base.alreadyVoted)
                    {
                        flag = true;
                        base.alreadyVoted = true;
                        shim = this.phase0EnlistmentShim;
                    }
                    base.realOletxTransaction.DecrementUndecidedEnlistments();
                }
            }
            try
            {
                if (flag && (shim != null))
                {
                    shim.Phase0Done(base.collectedVoteYes && !base.realOletxTransaction.Doomed);
                }
            }
            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)
            {
                string str = "OletxPhase0VolatileEnlistmentContainer.DecrementOutstandingNotifications";
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), str);
            }
        }
Exemplo n.º 24
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");
            }
        }
        public object GetRealObject(StreamingContext context)
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "IObjectReference.GetRealObject");
            }
            if (this.propagationTokenForDeserialize == null)
            {
                if (DiagnosticTrace.Critical)
                {
                    InternalErrorTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), System.Transactions.SR.GetString("UnableToDeserializeTransaction"));
                }
                throw TransactionException.Create(System.Transactions.SR.GetString("TraceSourceOletx"), System.Transactions.SR.GetString("UnableToDeserializeTransactionInternalError"), null);
            }
            if (null != this.savedLtmPromotedTransaction)
            {
                if (DiagnosticTrace.Verbose)
                {
                    MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "IObjectReference.GetRealObject");
                }
                return(this.savedLtmPromotedTransaction);
            }
            Transaction transactionFromTransmitterPropagationToken = TransactionInterop.GetTransactionFromTransmitterPropagationToken(this.propagationTokenForDeserialize);

            this.savedLtmPromotedTransaction = transactionFromTransmitterPropagationToken;
            if (DiagnosticTrace.Verbose)
            {
                TransactionDeserializedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), transactionFromTransmitterPropagationToken.internalTransaction.PromotedTransaction.TransactionTraceId);
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "IObjectReference.GetRealObject");
            }
            return(transactionFromTransmitterPropagationToken);
        }
Exemplo n.º 26
0
        public void InDoubt()
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                               "SinglePhaseEnlistment.InDoubt"
                                               );
            }


            lock (this.internalEnlistment.SyncRoot)
            {
                if (DiagnosticTrace.Warning)
                {
                    EnlistmentCallbackNegativeTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                                                this.internalEnlistment.EnlistmentTraceId,
                                                                EnlistmentCallback.InDoubt
                                                                );
                }

                this.internalEnlistment.State.InDoubt(this.internalEnlistment, null);
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                              "SinglePhaseEnlistment.InDoubt"
                                              );
            }
        }
Exemplo n.º 27
0
        internal override void InternalDispose()
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceLtm, "IDisposable.Dispose");
            }

            if (Interlocked.Exchange(ref _disposed, Transaction._disposedTrueValue) == Transaction._disposedTrueValue)
            {
                return;
            }

            if (_internalTransaction.State.get_Status(_internalTransaction) == TransactionStatus.Active)
            {
                lock (_internalTransaction)
                {
                    // Since this is the root transaction do state based dispose.
                    _internalTransaction.State.DisposeRoot(_internalTransaction);
                }
            }

            // Attempt to clean up the internal transaction
            long remainingITx = Interlocked.Decrement(ref _internalTransaction._cloneCount);

            if (remainingITx == 0)
            {
                _internalTransaction.Dispose();
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.TraceSourceLtm, "IDisposable.Dispose");
            }
        }
Exemplo n.º 28
0
        public void Aborted(Exception e)
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                               "SinglePhaseEnlistment.Aborted"
                                               );
            }

            if (DiagnosticTrace.Warning)
            {
                EnlistmentCallbackNegativeTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                                            this.internalEnlistment.EnlistmentTraceId,
                                                            EnlistmentCallback.Aborted
                                                            );
            }

            lock (this.internalEnlistment.SyncRoot)
            {
                this.internalEnlistment.State.Aborted(this.internalEnlistment, e);
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceLtm),
                                              "SinglePhaseEnlistment.Aborted"
                                              );
            }
        }
Exemplo n.º 29
0
        public IAsyncResult BeginCommit(AsyncCallback asyncCallback, object asyncState)
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceLtm, "CommittableTransaction.BeginCommit");
                TransactionCommitCalledTraceRecord.Trace(SR.TraceSourceLtm, TransactionTraceId);
            }

            if (Disposed)
            {
                throw new ObjectDisposedException(nameof(CommittableTransaction));
            }

            lock (_internalTransaction)
            {
                if (_complete)
                {
                    throw TransactionException.CreateTransactionCompletedException(SR.TraceSourceLtm, DistributedTxId);
                }

                // this.complete will get set to true when the transaction enters a state that is
                // beyond Phase0.
                _internalTransaction.State.BeginCommit(_internalTransaction, true, asyncCallback, asyncState);
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.TraceSourceLtm, "CommittableTransaction.BeginCommit");
            }

            return(this);
        }
Exemplo n.º 30
0
        static public void RecoveryComplete(
            Guid resourceManagerIdentifier
            )
        {
            if (resourceManagerIdentifier == Guid.Empty)
            {
                throw new ArgumentException(SR.GetString(SR.BadResourceManagerId), "resourceManagerIdentifier");
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceBase),
                                               "TransactionManager.RecoveryComplete"
                                               );
            }

            if (DiagnosticTrace.Information)
            {
                RecoveryCompleteTraceRecord.Trace(SR.GetString(SR.TraceSourceBase),
                                                  resourceManagerIdentifier
                                                  );
            }

            DistributedTransactionManager.ResourceManagerRecoveryComplete(resourceManagerIdentifier);

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceBase),
                                              "TransactionManager.RecoveryComplete"
                                              );
            }
        }