Ejemplo n.º 1
0
        private void ProcessInput(QueuedBlockMsg dataMsg)
        {
            dataMsg.GetMessageSize();
            if (this.m_newestMessage != null)
            {
                this.m_newestMessage.NextMsg = dataMsg;
                this.m_newestMessage         = dataMsg;
            }
            else
            {
                this.m_newestMessage = dataMsg;
                this.m_oldestMessage = dataMsg;
            }
            bool flag = BitMasker.IsOn((int)dataMsg.EmitContext.grbitOperationalFlags, 16);

            if (PassiveBlockMode.IsDebugTraceEnabled)
            {
                long num = StopwatchStamp.TicksToMicroSeconds(dataMsg.ReadDurationInTics);
                PassiveBlockMode.Tracer.TraceDebug((long)this.GetHashCode(), "MessageArrived({0}) Gen=0x{1:X} Sector=0x{2:X} JBits=0x{3:X} EmitSeq=0x{4:X} LogDataLen=0x{5:X} ReadUSec={6}", new object[]
                {
                    this.DatabaseName,
                    dataMsg.EmitContext.lgposLogData.lGeneration,
                    dataMsg.EmitContext.lgposLogData.isec,
                    (int)dataMsg.EmitContext.grbitOperationalFlags,
                    dataMsg.EmitContext.qwSequenceNum,
                    dataMsg.LogDataLength,
                    num
                });
            }
            this.Copier.PerfmonCounters.RecordGranularBytesReceived((long)dataMsg.LogDataLength, flag);
            ExchangeNetworkPerfmonCounters perfCounters = this.m_netChannel.PerfCounters;

            if (perfCounters != null)
            {
                perfCounters.RecordLogCopyThruputReceived((long)dataMsg.LogDataLength);
                if (dataMsg.CompressedLogDataLength > 0)
                {
                    perfCounters.RecordCompressedDataReceived(dataMsg.CompressedLogDataLength, dataMsg.LogDataLength, NetworkPath.ConnectionPurpose.LogCopy);
                }
            }
            this.TriggerConsumer();
            if (flag || DateTime.UtcNow >= this.m_nextPingDue)
            {
                uint lGeneration = (uint)dataMsg.EmitContext.lgposLogData.lGeneration;
                if (flag)
                {
                    this.Copier.TrackKnownEndOfLog((long)((ulong)lGeneration), dataMsg.EmitContext.logtimeEmit);
                }
                NetworkTransportException ex;
                bool flag2;
                this.TrySendStatusMessageToActive(flag ? PassiveStatusMsg.Flags.AckEndOfGeneration : PassiveStatusMsg.Flags.None, dataMsg.RequestAckCounter, out ex, out flag2);
                if (ex != null)
                {
                    throw ex;
                }
            }
        }
        // Token: 0x060017DB RID: 6107 RVA: 0x00062D0C File Offset: 0x00060F0C
        private int ReadCoconetBlock(byte[] buf, int off, int len)
        {
            if (this.m_coconetDecompressor == null)
            {
                this.m_coconetDecompressor = new CoconetDecompressor(this.CoconetConfig.DictionarySize, (CoconetCompressor.LzOption) this.CoconetConfig.LzOption);
            }
            if (this.m_xpressReadBuf == null || this.m_xpressReadBuf.Length < 1048577)
            {
                this.m_xpressReadBuf = new byte[1048577];
            }
            this.ReadChunk(this.m_readPacketHeaderBuf, 0, 8);
            int num  = BitConverter.ToInt32(this.m_readPacketHeaderBuf, 0);
            int num2 = BitConverter.ToInt32(this.m_readPacketHeaderBuf, 4);

            if (num2 > 1048577 || num2 <= 0)
            {
                throw new NetworkCorruptDataException(this.PartnerNodeName);
            }
            if (num > 1048577 || num <= 0)
            {
                throw new NetworkCorruptDataException(this.PartnerNodeName);
            }
            this.ReadChunk(this.m_xpressReadBuf, 0, num);
            ExTraceGlobals.NetShareTracer.TraceDebug <int, int>((long)this.GetHashCode(), "ReadCoconetBlock l={0} c={1}", num2, num);
            if (num2 <= len)
            {
                this.m_coconetDecompressor.Decompress(this.m_xpressReadBuf, 0, num, buf, off, num2);
            }
            else
            {
                if (this.m_decompressBuf == null || this.m_decompressBuf.Length < 1048577)
                {
                    this.m_decompressBuf = new byte[1048577];
                }
                this.m_coconetDecompressor.Decompress(this.m_xpressReadBuf, 0, num, this.m_decompressBuf, 0, num2);
            }
            ExchangeNetworkPerfmonCounters perfCounters = this.m_netChannel.PerfCounters;

            if (perfCounters != null && this.m_netChannel.NetworkPath != null)
            {
                perfCounters.RecordCompressedDataReceived(num, num2, this.m_netChannel.NetworkPath.Purpose);
            }
            this.TotalDecompressedBytesReceived += (long)num2;
            this.TotalCompressedBytesReceived   += (long)num;
            if (num2 <= len)
            {
                this.m_bytesRemainingToReadInCurrentBlock = 0;
                return(num2);
            }
            this.m_decompressBufContentLen            = num2;
            this.m_bytesRemainingToReadInCurrentBlock = num2 - len;
            Array.Copy(this.m_decompressBuf, 0, buf, off, len);
            NetworkPackagingLayer.Tracer.TraceError <int, int>((long)this.GetHashCode(), "NetPkg.ReadCoconetBlock: Had to buffer 0x{0:X} uncompressed bytes for the next fetch since only 0x{1:X} were requested.", this.m_bytesRemainingToReadInCurrentBlock, len);
            return(len);
        }
        // Token: 0x060017DA RID: 6106 RVA: 0x00062B9C File Offset: 0x00060D9C
        private int ReadXpressBlock(byte[] buf, int off, int len)
        {
            if (this.m_xpressReadBuf == null)
            {
                this.m_xpressReadBuf = new byte[65536];
            }
            this.ReadChunk(this.m_readPacketHeaderBuf, 0, 4);
            ushort num  = BitConverter.ToUInt16(this.m_readPacketHeaderBuf, 0);
            int    num2 = (int)(num + 1);

            num = BitConverter.ToUInt16(this.m_readPacketHeaderBuf, 2);
            int num3 = (int)(num + 1);

            this.ReadChunk(this.m_xpressReadBuf, 0, num2);
            bool flag;

            if (num3 <= len)
            {
                flag = Xpress.Decompress(this.m_xpressReadBuf, 0, num2, buf, off, num3);
            }
            else
            {
                if (this.m_decompressBuf == null)
                {
                    this.m_decompressBuf = new byte[65536];
                }
                flag = Xpress.Decompress(this.m_xpressReadBuf, 0, num2, this.m_decompressBuf, 0, num3);
            }
            if (!flag)
            {
                NetworkPackagingLayer.Tracer.TraceError((long)this.GetHashCode(), "Decompression failed");
                throw new NetworkCorruptDataException(this.PartnerNodeName);
            }
            ExchangeNetworkPerfmonCounters perfCounters = this.m_netChannel.PerfCounters;

            if (perfCounters != null && this.m_netChannel.NetworkPath != null)
            {
                perfCounters.RecordCompressedDataReceived(num2, num3, this.m_netChannel.NetworkPath.Purpose);
            }
            this.TotalDecompressedBytesReceived += (long)num3;
            this.TotalCompressedBytesReceived   += (long)num2;
            if (num3 <= len)
            {
                this.m_bytesRemainingToReadInCurrentBlock = 0;
                return(num3);
            }
            this.m_decompressBufContentLen            = num3;
            this.m_bytesRemainingToReadInCurrentBlock = num3 - len;
            Array.Copy(this.m_decompressBuf, 0, buf, off, len);
            NetworkPackagingLayer.Tracer.TraceError <int, int>((long)this.GetHashCode(), "NetPkg.ReadXpressBlock: Had to buffer 0x{0:X} uncompressed bytes for the next fetch since only 0x{1:X} were requested.", this.m_bytesRemainingToReadInCurrentBlock, len);
            return(len);
        }