コード例 #1
0
ファイル: SNIMarsHandle.cs プロジェクト: vikas304/SqlClient
        /// <summary>
        /// Send control packet
        /// </summary>
        /// <param name="flags">SMUX header flags</param>
        private void SendControlPacket(SNISMUXFlags flags)
        {
            long scopeID = SqlClientEventSource.Log.TrySNIScopeEnterEvent("SNIMarsHandle.SendControlPacket | SNI | INFO | SCOPE | Entering Scope {0}");

            try
            {
                SNIPacket packet = RentPacket(headerSize: SNISMUXHeader.HEADER_LENGTH, dataSize: 0);
#if DEBUG
                SqlClientEventSource.Log.TrySNITraceEvent(s_className, EventType.INFO, "MARS Session Id {0}, Packet rented {1}, packet dataLeft {2}", args0: ConnectionId, args1: packet?._id, args2: packet?.DataLeft);
#endif
                lock (this)
                {
                    SetupSMUXHeader(0, flags);
                    _currentHeader.Write(packet.GetHeaderBuffer(SNISMUXHeader.HEADER_LENGTH));
                    packet.SetHeaderActive();
                }

                _connection.Send(packet);
                ReturnPacket(packet);
#if DEBUG
                SqlClientEventSource.Log.TrySNITraceEvent(s_className, EventType.INFO, "MARS Session Id {0}, Packet returned {1}, packet dataLeft {2}", args0: ConnectionId, args1: packet?._id, args2: packet?.DataLeft);
                ;
#endif
            }
            finally
            {
                SqlClientEventSource.Log.TrySNIScopeLeaveEvent(scopeID);
            }
        }
コード例 #2
0
 private void SetupSMUXHeader(int length, SNISMUXFlags flags)
 {
     Debug.Assert(Monitor.IsEntered(this), "must take lock on self before updating mux header");
     _currentHeader.SMID           = 83;
     _currentHeader.flags          = (byte)flags;
     _currentHeader.sessionId      = _sessionId;
     _currentHeader.length         = (uint)SNISMUXHeader.HEADER_LENGTH + (uint)length;
     _currentHeader.sequenceNumber = ((flags == SNISMUXFlags.SMUX_FIN) || (flags == SNISMUXFlags.SMUX_ACK)) ? _sequenceNumber - 1 : _sequenceNumber++;
     _currentHeader.highwater      = _receiveHighwater;
     _receiveHighwaterLastAck      = _currentHeader.highwater;
 }
コード例 #3
0
        private void GetSMUXHeaderBytes(int length, SNISMUXFlags flags, Span <byte> bytes)
        {
            _currentHeader.SMID           = 83;
            _currentHeader.flags          = (byte)flags;
            _currentHeader.sessionId      = _sessionId;
            _currentHeader.length         = (uint)SNISMUXHeader.HEADER_LENGTH + (uint)length;
            _currentHeader.sequenceNumber = ((flags == SNISMUXFlags.SMUX_FIN) || (flags == SNISMUXFlags.SMUX_ACK)) ? _sequenceNumber - 1 : _sequenceNumber++;
            _currentHeader.highwater      = _receiveHighwater;
            _receiveHighwaterLastAck      = _currentHeader.highwater;

            _currentHeader.Write(bytes);
        }
コード例 #4
0
        /// <summary>
        /// Send control packet
        /// </summary>
        /// <param name="flags">SMUX header flags</param>
        private void SendControlPacket(SNISMUXFlags flags)
        {
            SNIPacket packet = new SNIPacket(headerSize: SNISMUXHeader.HEADER_LENGTH, dataSize: 0);

            lock (this)
            {
                SetupSMUXHeader(0, flags);
                _currentHeader.Write(packet.GetHeaderBuffer(SNISMUXHeader.HEADER_LENGTH));
                packet.SetHeaderActive();
            }
            _connection.Send(packet);
        }
コード例 #5
0
ファイル: SNIMarsHandle.cs プロジェクト: rsumner31/corefx2
        /// <summary>
        /// Send control packet
        /// </summary>
        /// <param name="flags">SMUX header flags</param>
        private void SendControlPacket(SNISMUXFlags flags)
        {
            byte[] headerBytes = null;

            lock (this)
            {
                GetSMUXHeaderBytes(0, (byte)flags, ref headerBytes);
            }

            SNIPacket packet = new SNIPacket();

            packet.SetData(headerBytes, SNISMUXHeader.HEADER_LENGTH);

            _connection.Send(packet);
        }
コード例 #6
0
        /// <summary>
        /// Send control packet
        /// </summary>
        /// <param name="flags">SMUX header flags</param>
        private void SendControlPacket(SNISMUXFlags flags)
        {
            Span <byte> headerBytes = stackalloc byte[SNISMUXHeader.HEADER_LENGTH];

            lock (this)
            {
                GetSMUXHeaderBytes(0, flags, headerBytes);
            }

            SNIPacket packet = new SNIPacket(SNISMUXHeader.HEADER_LENGTH);

            packet.AppendData(headerBytes);

            _connection.Send(packet);
        }
コード例 #7
0
ファイル: SNIMarsHandle.cs プロジェクト: mbakalov/SqlClient
        private SNISMUXHeader SetupSMUXHeader(int length, SNISMUXFlags flags)
        {
            Debug.Assert(Monitor.IsEntered(this), "must take lock on self before updating smux header");

            SNISMUXHeader header = new SNISMUXHeader();

            header.Set(
                smid: 83,
                flags: (byte)flags,
                sessionID: _sessionId,
                length: (uint)SNISMUXHeader.HEADER_LENGTH + (uint)length,
                sequenceNumber: ((flags == SNISMUXFlags.SMUX_FIN) || (flags == SNISMUXFlags.SMUX_ACK)) ? _sequenceNumber - 1 : _sequenceNumber++,
                highwater: _receiveHighwater
                );
            _receiveHighwaterLastAck = header.Highwater;

            return(header);
        }
コード例 #8
0
        /// <summary>
        /// Send control packet
        /// </summary>
        /// <param name="flags">SMUX header flags</param>
        /// <param name="async">true if packet should be sent asynchronously</param>
        private void SendControlPacket(SNISMUXFlags flags, bool async)
        {
            byte[] headerBytes = null;

            lock (this)
            {
                GetSMUXHeaderBytes(0, (byte)flags, ref headerBytes);
            }

            SNIPacket packet = new SNIPacket(null);

            packet.SetData(headerBytes, SNISMUXHeader.HEADER_LENGTH);

            if (async)
            {
                _connection.SendAsync(packet, (sentPacket, error) => { });
            }
            else
            {
                _connection.Send(packet);
            }
        }
コード例 #9
0
ファイル: SNIMarsHandle.cs プロジェクト: ymf1/SqlClient
        /// <summary>
        /// Send control packet
        /// </summary>
        /// <param name="flags">SMUX header flags</param>
        private void SendControlPacket(SNISMUXFlags flags)
        {
            long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent("<sc.SNI.SNIMarsHandle.SendControlPacket |SNI|INFO|SCOPE>");

            try
            {
                SNIPacket packet = new SNIPacket(headerSize: SNISMUXHeader.HEADER_LENGTH, dataSize: 0);

                lock (this)
                {
                    SetupSMUXHeader(0, flags);
                    _currentHeader.Write(packet.GetHeaderBuffer(SNISMUXHeader.HEADER_LENGTH));
                    packet.SetHeaderActive();
                }

                _connection.Send(packet);
            }
            finally
            {
                SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID);
            }
        }
コード例 #10
0
        /// <summary>
        /// Send control packet
        /// </summary>
        /// <param name="flags">SMUX header flags</param>
        /// <param name="async">true if packet should be sent asynchronously</param>
        /// <returns>True if completed successfully, otherwise false</returns>
        private SNIError SendControlPacket(SNISMUXFlags flags, bool async)
        {
            byte[] headerBytes = null;

            lock (this)
            {
                GetSMUXHeaderBytes(0, (byte)flags, ref headerBytes);
            }

            SNIPacket packet = new SNIPacket(headerBytes, SNISMUXHeader.HEADER_LENGTH);

            if (async)
            {
                SNIError sniError;
                _connection.SendAsync(packet, NullCallback, false, out sniError);
                return(sniError);
            }
            else
            {
                return(_connection.Send(packet));
            }
        }
コード例 #11
0
ファイル: SNIMarsHandle.cs プロジェクト: mbakalov/SqlClient
        /// <summary>
        /// Send control packet
        /// </summary>
        /// <param name="flags">SMUX header flags</param>
        private void SendControlPacket(SNISMUXFlags flags)
        {
            using (TrySNIEventScope.Create("SNIMarsHandle.SendControlPacket | SNI | INFO | SCOPE | Entering Scope {0}"))
            {
                SNIPacket packet = RentPacket(headerSize: SNISMUXHeader.HEADER_LENGTH, dataSize: 0);
#if DEBUG
                SqlClientEventSource.Log.TrySNITraceEvent(nameof(SNIMarsHandle), EventType.INFO, "MARS Session Id {0}, Packet rented {1}, packet dataLeft {2}", args0: ConnectionId, args1: packet?._id, args2: packet?.DataLeft);
#endif
                lock (this)
                {
                    SNISMUXHeader header = SetupSMUXHeader(0, flags);
                    header.Write(packet.GetHeaderBuffer(SNISMUXHeader.HEADER_LENGTH));
                    packet.SetHeaderActive();
                }

                _connection.Send(packet);
                ReturnPacket(packet);
#if DEBUG
                SqlClientEventSource.Log.TrySNITraceEvent(nameof(SNIMarsHandle), EventType.INFO, "MARS Session Id {0}, Packet returned {1}, packet dataLeft {2}", args0: ConnectionId, args1: packet?._id, args2: packet?.DataLeft);
                ;
#endif
            }
        }
コード例 #12
0
ファイル: SNIMarsHandle.cs プロジェクト: hyjiacan/corefx
        /// <summary>
        /// Send control packet
        /// </summary>
        /// <param name="flags">SMUX header flags</param>
        private void SendControlPacket(SNISMUXFlags flags)
        {
            byte[] headerBytes = null;

            lock (this)
            {
                GetSMUXHeaderBytes(0, (byte)flags, ref headerBytes);
            }

            SNIPacket packet = new SNIPacket(null);
            packet.SetData(headerBytes, SNISMUXHeader.HEADER_LENGTH);
            
            _connection.Send(packet);
        }
コード例 #13
0
ファイル: SNIMarsHandle.cs プロジェクト: CheetahChrome/corefx
        /// <summary>
        /// Send control packet
        /// </summary>
        /// <param name="flags">SMUX header flags</param>
        /// <param name="async">true if packet should be sent asynchronously</param>
        private void SendControlPacket(SNISMUXFlags flags, bool async)
        {
            byte[] headerBytes = null;

            lock (this)
            {
                GetSMUXHeaderBytes(0, (byte)flags, ref headerBytes);
            }

            SNIPacket packet = new SNIPacket(null);
            packet.SetData(headerBytes, SNISMUXHeader.HEADER_LENGTH);

            if (async)
            {
                _connection.SendAsync(packet, (sentPacket, error) => { });
            }
            else
            {
                _connection.Send(packet);
            }
        }