コード例 #1
0
        internal TdsParserStateObject GetSession(object owner)
        {
            TdsParserStateObject session;

            lock (_cache)
            {
                if (IsDisposed)
                {
                    throw ADP.ClosedConnectionError();
                }
                else if (_freeStateObjectCount > 0)
                {
                    // Free state object - grab it
                    _freeStateObjectCount--;
                    session = _freeStateObjects[_freeStateObjectCount];
                    _freeStateObjects[_freeStateObjectCount] = null;
                    Debug.Assert(session != null, "There was a null session in the free session list?");
                }
                else
                {
                    // No free objects, create a new one
                    session = _parser.CreateSession();


                    _cache.Add(session);
                    _cachedCount = _cache.Count;
                }

                session.Activate(owner);
            }


            return(session);
        }
コード例 #2
0
        internal TdsParserStateObject GetSession(object owner)
        {
            TdsParserStateObject session;

            lock (_cache)
            {
                if (IsDisposed)
                {
                    throw ADP.ClosedConnectionError();
                }
                else if (_freeStateObjectCount > 0)
                {
                    // Free state object - grab it
                    _freeStateObjectCount--;
                    session = _freeStateObjects[_freeStateObjectCount];
                    _freeStateObjects[_freeStateObjectCount] = null;
                    Debug.Assert(session != null, "There was a null session in the free session list?");
                }
                else
                {
                    // No free objects, create a new one
                    session = _parser.CreateSession();
                    SqlClientEventSource.Log.TryAdvancedTraceEvent("<sc.TdsParserSessionPool.CreateSession|ADV> {0} adding session {1} to pool", ObjectID, session.ObjectID);

                    _cache.Add(session);
                    _cachedCount = _cache.Count;
                }

                session.Activate(owner);
            }
            SqlClientEventSource.Log.TryAdvancedTraceEvent("<sc.TdsParserSessionPool.GetSession|ADV> {0} using session {1}", ObjectID, session.ObjectID);
            return(session);
        }
コード例 #3
0
 internal SqlInternalConnectionTds GetOpenTdsConnection()
 {
     SqlInternalConnectionTds innerConnection = this.InnerConnection as SqlInternalConnectionTds;
     if (innerConnection == null)
     {
         throw ADP.ClosedConnectionError();
     }
     return innerConnection;
 }
コード例 #4
0
ファイル: SqlConnection.cs プロジェクト: zuhuizou/corefx
        //
        // PRIVATE METHODS
        //


        internal SqlInternalConnectionTds GetOpenTdsConnection()
        {
            SqlInternalConnectionTds innerConnection = (InnerConnection as SqlInternalConnectionTds);

            if (null == innerConnection)
            {
                throw ADP.ClosedConnectionError();
            }
            return(innerConnection);
        }
コード例 #5
0
        internal override PacketHandle ReadSyncOverAsync(int timeoutRemaining, out uint error)
        {
            SNIHandle handle = Handle;

            if (handle == null)
            {
                throw ADP.ClosedConnectionError();
            }
            error = SNIProxy.GetInstance().ReadSyncOverAsync(handle, out SNIPacket packet, timeoutRemaining);
            return(PacketHandle.FromManagedPacket(packet));
        }
コード例 #6
0
        //
        // Public methods
        //
        public void ExecuteAndSend(SqlCommand command)
        {
            SetPipeBusy( );
            try {
                EnsureNormalSendValid("ExecuteAndSend");

                if (null == command)
                {
                    throw ADP.ArgumentNull("command");
                }

                SqlConnection connection = command.Connection;

                // if the command doesn't have a connection set up, try to set one up on it's behalf
                if (null == connection)
                {
                    using (SqlConnection newConnection = new SqlConnection("Context Connection=true")) {
                        newConnection.Open( );

                        // use try-finally to restore command's connection property to it's original state
                        try {
                            command.Connection = newConnection;
                            command.ExecuteToPipe(_smiContext);
                        }
                        finally {
                            command.Connection = null;
                        }
                    }
                }
                else
                {
                    // validate connection state
                    if (ConnectionState.Open != connection.State)
                    {
                        throw ADP.ClosedConnectionError();
                    }

                    // validate connection is current scope's connection
                    SqlInternalConnectionSmi internalConnection = connection.InnerConnection as SqlInternalConnectionSmi;

                    if (null == internalConnection)
                    {
                        throw SQL.SqlPipeCommandHookedUpToNonContextConnection( );
                    }

                    command.ExecuteToPipe(_smiContext);
                }
            }
            finally {
                ClearPipeBusy( );
            }
        }
コード例 #7
0
        internal override PacketHandle ReadSyncOverAsync(int timeoutRemaining, out uint error)
        {
            SNIHandle handle = Handle;

            if (handle == null)
            {
                throw ADP.ClosedConnectionError();
            }
            IntPtr readPacketPtr = IntPtr.Zero;

            error = SNINativeMethodWrapper.SNIReadSyncOverAsync(handle, ref readPacketPtr, GetTimeoutRemaining());
            return(PacketHandle.FromNativePointer(readPacketPtr));
        }
コード例 #8
0
        internal override object ReadSyncOverAsync(int timeoutRemaining, out uint error)
        {
            SNIHandle handle = Handle;

            if (handle == null)
            {
                throw ADP.ClosedConnectionError();
            }
            SNIPacket packet = null;

            error = SNIProxy.Singleton.ReadSyncOverAsync(handle, out packet, timeoutRemaining);
            return(packet);
        }
コード例 #9
0
        internal TdsParserStateObject GetSession(object owner)
        {
            TdsParserStateObject session;
            bool createSession = false;

            lock (_cache)
            {
                if (IsDisposed)
                {
                    throw ADP.ClosedConnectionError();
                }
                else if (_freeStateObjectCount > 0)
                {
                    // Free state object - grab it
                    _freeStateObjectCount--;
                    session = _freeStateObjects[_freeStateObjectCount];
                    _freeStateObjects[_freeStateObjectCount] = null;
                    Debug.Assert(session != null, "There was a null session in the free session list?");
                }
                else
                {
                    // No free objects, create a new on
                    session       = null;
                    createSession = true;
                }
            }

            if (createSession)
            {
                _parser.Connection._parserLock.Wait(canReleaseFromAnyThread: false);
                try
                {
                    session = _parser.CreateSession();
                }
                finally
                {
                    _parser.Connection._parserLock.Release();
                }

                lock (_cache)
                {
                    _cache.Add(session);
                }
            }

            session.Activate(owner);

            return(session);
        }
コード例 #10
0
        internal override PacketHandle ReadSyncOverAsync(int timeoutRemaining, out uint error)
        {
            SNIHandle handle = Handle;

            if (handle == null)
            {
                throw ADP.ClosedConnectionError();
            }
            error = SNIProxy.GetInstance().ReadSyncOverAsync(handle, out SNIPacket packet, timeoutRemaining);
            SqlClientEventSource.Log.TryTraceEvent("TdsParserStateObjectManaged.ReadSyncOverAsync | Info | State Object Id {0}, Session Id {1}", _objectID, _sessionHandle?.ConnectionId);
#if DEBUG
            SqlClientEventSource.Log.TryAdvancedTraceEvent("TdsParserStateObjectManaged.ReadSyncOverAsync | TRC | State Object Id {0}, Session Id {1}, Packet {2} received, Packet owner Id {3}, Packet dataLeft {4}", _objectID, _sessionHandle?.ConnectionId, packet?._id, packet?._owner.ConnectionId, packet?.DataLeft);
#endif
            return(PacketHandle.FromManagedPacket(packet));
        }
コード例 #11
0
        internal override object ReadSyncOverAsync(int timeoutRemaining, bool isMarsOn, out uint error)
        {
            SNIHandle handle = Handle;

            if (handle == null)
            {
                throw ADP.ClosedConnectionError();
            }
            if (isMarsOn)
            {
                IncrementPendingCallbacks();
            }
            SNIPacket packet = null;

            error = SNIProxy.Singleton.ReadSyncOverAsync(handle, out packet, timeoutRemaining);
            return(packet);
        }
コード例 #12
0
 public void ExecuteAndSend(SqlCommand command)
 {
     this.SetPipeBusy();
     try
     {
         this.EnsureNormalSendValid("ExecuteAndSend");
         if (command == null)
         {
             throw ADP.ArgumentNull("command");
         }
         SqlConnection connection2 = command.Connection;
         if (connection2 == null)
         {
             using (SqlConnection connection = new SqlConnection("Context Connection=true"))
             {
                 connection.Open();
                 try
                 {
                     command.Connection = connection;
                     command.ExecuteToPipe(this._smiContext);
                 }
                 finally
                 {
                     command.Connection = null;
                 }
                 return;
             }
         }
         if (ConnectionState.Open != connection2.State)
         {
             throw ADP.ClosedConnectionError();
         }
         if (!(connection2.InnerConnection is SqlInternalConnectionSmi))
         {
             throw SQL.SqlPipeCommandHookedUpToNonContextConnection();
         }
         command.ExecuteToPipe(this._smiContext);
     }
     finally
     {
         this.ClearPipeBusy();
     }
 }
コード例 #13
0
        internal TdsParserStateObject GetSession(object owner)
        {
            TdsParserStateObject session;

            lock (_cache)
            {
                if (IsDisposed)
                {
                    throw ADP.ClosedConnectionError();
                }
                else if (_freeStateObjectCount > 0)
                {
                    // Free state object - grab it
                    _freeStateObjectCount--;
                    session = _freeStateObjects[_freeStateObjectCount];
                    _freeStateObjects[_freeStateObjectCount] = null;
                    Debug.Assert(session != null, "There was a null session in the free session list?");
                }
                else
                {
                    // No free objects, create a new one
                    session = _parser.CreateSession();

                    if (Bid.AdvancedOn)
                    {
                        Bid.Trace("<sc.TdsParserSessionPool.CreateSession|ADV> %d# adding session %d to pool\n", ObjectID, session.ObjectID);
                    }

                    _cache.Add(session);
                    _cachedCount = _cache.Count;
                }

                session.Activate(owner);
            }

            if (Bid.AdvancedOn)
            {
                Bid.Trace("<sc.TdsParserSessionPool.GetSession|ADV> %d# using session %d\n", ObjectID, session.ObjectID);
            }

            return(session);
        }
コード例 #14
0
 override public void EnlistTransaction(SysTx.Transaction transaction)
 {
     throw ADP.ClosedConnectionError();
 }
コード例 #15
0
 override public void ChangeDatabase(string database)
 {
     throw ADP.ClosedConnectionError();
 }
コード例 #16
0
 override protected void Deactivate()
 {
     throw ADP.ClosedConnectionError();
 }
コード例 #17
0
 override protected void Activate(SysTx.Transaction transaction)
 {
     throw ADP.ClosedConnectionError();
 }
コード例 #18
0
 override public DbTransaction BeginTransaction(IsolationLevel il)
 {
     throw ADP.ClosedConnectionError();
 }
コード例 #19
0
 protected override void Deactivate() => ADP.ClosedConnectionError();
コード例 #20
0
 override protected internal DataTable GetSchema(DbConnectionFactory factory, DbConnectionPoolGroup poolGroup, DbConnection outerConnection, string collectionName, string[] restrictions)
 {
     throw ADP.ClosedConnectionError();
 }
コード例 #21
0
 public override void EnlistTransaction(Transaction transaction)
 {
     throw ADP.ClosedConnectionError();
 }
コード例 #22
0
 protected override void Activate(Transaction transaction)
 {
     throw ADP.ClosedConnectionError();
 }
コード例 #23
0
 protected override void Activate() => throw ADP.ClosedConnectionError();
コード例 #24
0
 protected override DbReferenceCollection CreateReferenceCollection()
 {
     throw ADP.ClosedConnectionError();
 }
コード例 #25
0
 public override DbTransaction BeginTransaction(System.Data.IsolationLevel il)
 {
     throw ADP.ClosedConnectionError();
 }