示例#1
0
        internal override void ReleasePacket(PacketHandle syncReadPacket)
        {
            SNIPacket packet = syncReadPacket.ManagedPacket;

            if (packet != null)
            {
                SNIHandle handle = Handle;
                handle.ReturnPacket(packet);
            }
        }
示例#2
0
        internal override void ReleasePacket(PacketHandle syncReadPacket)
        {
            SNIPacket packet = syncReadPacket.ManagedPacket;

            SqlClientEventSource.Log.TryTraceEvent("TdsParserStateObjectManaged.ReleasePacket | Info | State Object Id {0}, Session Id {1}, Packet DataLeft {2}", _objectID, _sessionHandle?.ConnectionId, packet?.DataLeft);
#if DEBUG
            SqlClientEventSource.Log.TryAdvancedTraceEvent("TdsParserStateObjectManaged.ReleasePacket | TRC | State Object Id {0}, Session Id {1}, Packet {2} will be released, Packet Owner Id {3}, Packet dataLeft {4}", _objectID, _sessionHandle?.ConnectionId, packet?._id, packet?._owner.ConnectionId, packet?.DataLeft);
#endif
            if (packet != null)
            {
                SNIHandle handle = Handle;
                handle.ReturnPacket(packet);
            }
        }
示例#3
0
        /// <summary>
        /// Send a packet
        /// </summary>
        /// <param name="handle">SNI handle</param>
        /// <param name="packet">SNI packet</param>
        /// <param name="sync">true if synchronous, false if asynchronous</param>
        /// <returns>SNI error status</returns>
        internal uint WritePacket(SNIHandle handle, SNIPacket packet, bool sync)
        {
            uint result;

            if (sync)
            {
                result = handle.Send(packet);
                handle.ReturnPacket(packet);
            }
            else
            {
                result = handle.SendAsync(packet);
            }

            return(result);
        }
        internal void WriteAsyncCallback(SNIPacket packet, uint sniError)
        {
            SNIHandle sessionHandle = _sessionHandle;

            if (sessionHandle != null)
            {
                WriteAsyncCallback(IntPtr.Zero, PacketHandle.FromManagedPacket(packet), sniError);
                sessionHandle?.ReturnPacket(packet);
            }
            else
            {
                // clear the packet and drop it to GC because we no longer know how to return it to the correct owner
                // this can only happen if a packet is in-flight when the _sessionHandle is cleared
                packet.Release();
            }
        }
示例#5
0
        /// <summary>
        /// Send a packet
        /// </summary>
        /// <param name="handle">SNI handle</param>
        /// <param name="packet">SNI packet</param>
        /// <param name="sync">true if synchronous, false if asynchronous</param>
        /// <returns>SNI error status</returns>
        internal uint WritePacket(SNIHandle handle, SNIPacket packet, bool sync)
        {
            uint result;

            if (sync)
            {
                result = handle.Send(packet);
                handle.ReturnPacket(packet);
            }
            else
            {
                result = handle.SendAsync(packet);
            }

            SqlClientEventSource.Log.TryTraceEvent("SNIProxy.WritePacket | Info | Session Id {0}, SendAsync Result {1}", handle?.ConnectionId, result);
            return(result);
        }
        internal override uint WritePacket(PacketHandle packetHandle, bool sync)
        {
            uint      result;
            SNIHandle handle = Handle;
            SNIPacket packet = packetHandle.ManagedPacket;

            if (sync)
            {
                result = handle.Send(packet);
                handle.ReturnPacket(packet);
            }
            else
            {
                result = handle.SendAsync(packet);
            }

            SqlClientEventSource.Log.TryTraceEvent("TdsParserStateObjectManaged.WritePacket | Info | Session Id {0}, SendAsync Result {1}", handle?.ConnectionId, result);
            return(result);
        }
示例#7
0
        internal void ReadAsyncCallback(SNIPacket packet, uint error)
        {
            SNIHandle sessionHandle = _sessionHandle;

            if (sessionHandle != null)
            {
                ReadAsyncCallback(IntPtr.Zero, PacketHandle.FromManagedPacket(packet), error);
                SqlClientEventSource.Log.TryTraceEvent("TdsParserStateObjectManaged.ReadAsyncCallback | Info | State Object Id {0}, Session Id {1}, Error code returned {2}", _objectID, _sessionHandle?.ConnectionId, error);
#if DEBUG
                SqlClientEventSource.Log.TryAdvancedTraceEvent("TdsParserStateObjectManaged.ReadAsyncCallback | TRC | State Object Id {0}, Session Id {1}, Packet Id = {2}, Error code returned {3}", _objectID, _sessionHandle?.ConnectionId, packet?._id, error);
#endif
                sessionHandle?.ReturnPacket(packet);
            }
            else
            {
                // clear the packet and drop it to GC because we no longer know how to return it to the correct owner
                // this can only happen if a packet is in-flight when the _sessionHandle is cleared
                packet.Release();
            }
        }
示例#8
0
 public void ReturnPacket(SNIPacket packet)
 {
     _lowerHandle.ReturnPacket(packet);
 }
示例#9
0
 internal void ReadAsyncCallback(SNIPacket packet, uint error)
 {
     ReadAsyncCallback(IntPtr.Zero, PacketHandle.FromManagedPacket(packet), error);
     _sessionHandle.ReturnPacket(packet);
 }