internal override void Dispose() { SNIPacket packetHandle = _sniPacket; SNIHandle sessionHandle = _sessionHandle; SNIPacket asyncAttnPacket = _sniAsyncAttnPacket; _sniPacket = null; _sessionHandle = null; _sniAsyncAttnPacket = null; _marsConnection = null; DisposeCounters(); if (null != sessionHandle || null != packetHandle) { packetHandle?.Dispose(); asyncAttnPacket?.Dispose(); if (sessionHandle != null) { sessionHandle.Dispose(); DecrementPendingCallbacks(true); // Will dispose of GC handle. } } DisposePacketCache(); }
/// <summary> /// Constructor /// </summary> /// <param name="connection">MARS connection</param> /// <param name="sessionId">MARS session ID</param> /// <param name="callbackObject">Callback object</param> /// <param name="async">true if connection is asynchronous</param> public SNIMarsHandle(SNIMarsConnection connection, ushort sessionId, object callbackObject, bool async) { _sessionId = sessionId; _connection = connection; _callbackObject = callbackObject; SendControlPacket(SNISMUXFlags.SMUX_SYN); _status = TdsEnums.SNI_SUCCESS; }
internal override uint EnableMars(ref uint info) { _marsConnection = new SNIMarsConnection(Handle); if (_marsConnection.StartReceive() == TdsEnums.SNI_SUCCESS_IO_PENDING) { return(TdsEnums.SNI_SUCCESS); } return(TdsEnums.SNI_ERROR); }
/// <summary> /// Constructor /// </summary> /// <param name="connection">MARS connection</param> /// <param name="sessionId">MARS session ID</param> /// <param name="callbackObject">Callback object</param> /// <param name="async">true if connection is asynchronous</param> public SNIMarsHandle(SNIMarsConnection connection, ushort sessionId, object callbackObject, bool async) { _sessionId = sessionId; _connection = connection; _connectionId = connection.ConnectionId; _callbackObject = callbackObject; _handleSendCompleteCallback = HandleSendComplete; SendControlPacket(SNISMUXFlags.SMUX_SYN); SqlClientEventSource.Log.TrySNITraceEvent(nameof(SNIMarsHandle), EventType.INFO, "MARS Session Id {0}, Sent SMUX_SYN packet to start a new session, session Id {1}", args0: ConnectionId, args1: _sessionId); _status = TdsEnums.SNI_SUCCESS; }
internal override uint EnableMars(ref uint info) { _marsConnection = new SNIMarsConnection(Handle); SqlClientEventSource.Log.TryTraceEvent("TdsParserStateObjectManaged.EnableMars | Info | State Object Id {0}, Session Id {1}", _objectID, _sessionHandle?.ConnectionId); if (_marsConnection.StartReceive() == TdsEnums.SNI_SUCCESS_IO_PENDING) { return(TdsEnums.SNI_SUCCESS); } return(TdsEnums.SNI_ERROR); }
internal override void Dispose() { SNIHandle sessionHandle = _sessionHandle; _sessionHandle = null; _marsConnection = null; DisposeCounters(); if (null != sessionHandle) { sessionHandle.Dispose(); DecrementPendingCallbacks(true); // Will dispose of GC handle. } }
internal override void Dispose() { SqlClientEventSource.Log.TryTraceEvent("TdsParserStateObjectManaged.Dispose | Info | State Object Id {0}, Session Id {1}, Disposing session Handle and counters.", _objectID, _sessionHandle?.ConnectionId); SNIHandle sessionHandle = _sessionHandle; _sessionHandle = null; _marsConnection = null; DisposeCounters(); if (null != sessionHandle) { SqlClientEventSource.Log.TryTraceEvent("TdsParserStateObjectManaged.Dispose | Info | State Object Id {0}, Session Id {1}, sessionHandle is available, disposing session.", _objectID, _sessionHandle?.ConnectionId); sessionHandle.Dispose(); DecrementPendingCallbacks(true); // Will dispose of GC handle. } else { SqlClientEventSource.Log.TryTraceEvent("TdsParserStateObjectManaged.Dispose | Info | State Object Id {0}, sessionHandle not available, could not dispose session.", _objectID); } }