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); }
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); }
internal SqlInternalConnectionTds GetOpenTdsConnection() { SqlInternalConnectionTds innerConnection = this.InnerConnection as SqlInternalConnectionTds; if (innerConnection == null) { throw ADP.ClosedConnectionError(); } return innerConnection; }
// // PRIVATE METHODS // internal SqlInternalConnectionTds GetOpenTdsConnection() { SqlInternalConnectionTds innerConnection = (InnerConnection as SqlInternalConnectionTds); if (null == innerConnection) { throw ADP.ClosedConnectionError(); } return(innerConnection); }
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)); }
// // 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( ); } }
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)); }
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); }
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); }
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)); }
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); }
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(); } }
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); }
override public void EnlistTransaction(SysTx.Transaction transaction) { throw ADP.ClosedConnectionError(); }
override public void ChangeDatabase(string database) { throw ADP.ClosedConnectionError(); }
override protected void Deactivate() { throw ADP.ClosedConnectionError(); }
override protected void Activate(SysTx.Transaction transaction) { throw ADP.ClosedConnectionError(); }
override public DbTransaction BeginTransaction(IsolationLevel il) { throw ADP.ClosedConnectionError(); }
protected override void Deactivate() => ADP.ClosedConnectionError();
override protected internal DataTable GetSchema(DbConnectionFactory factory, DbConnectionPoolGroup poolGroup, DbConnection outerConnection, string collectionName, string[] restrictions) { throw ADP.ClosedConnectionError(); }
public override void EnlistTransaction(Transaction transaction) { throw ADP.ClosedConnectionError(); }
protected override void Activate(Transaction transaction) { throw ADP.ClosedConnectionError(); }
protected override void Activate() => throw ADP.ClosedConnectionError();
protected override DbReferenceCollection CreateReferenceCollection() { throw ADP.ClosedConnectionError(); }
public override DbTransaction BeginTransaction(System.Data.IsolationLevel il) { throw ADP.ClosedConnectionError(); }