summaryrefslogtreecommitdiff
path: root/indra/llmessage/message.cpp
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2026-09-01 18:35:23 +0800
committerErik Kundiman <erik@megapahit.org>2026-09-04 21:58:53 +0800
commit00bb3bb6f07660bd914d29a1389342bb3060d254 (patch)
tree431f574922494d2201718f13085f17bc6bd7fb42 /indra/llmessage/message.cpp
parenta8636720129952c10cf49ab80da21bf8b340b96c (diff)
parent4ef9f8f14b35ed388c294d53767a0dca0e890924 (diff)
Merge remote-tracking branch 'secondlife/release/26.4' into 26.4
Diffstat (limited to 'indra/llmessage/message.cpp')
-rw-r--r--indra/llmessage/message.cpp526
1 files changed, 354 insertions, 172 deletions
diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp
index e2937490ba..71210f7535 100644
--- a/indra/llmessage/message.cpp
+++ b/indra/llmessage/message.cpp
@@ -67,6 +67,7 @@
#include "llsdmessagereader.h"
#include "llsdserialize.h"
#include "llstring.h"
+#include "llzerocode.h"
#include "lltransfermanager.h"
#include "lluuid.h"
#include "llxfermanager.h"
@@ -78,6 +79,8 @@
#include "lltransfertargetvfile.h"
#include "llcorehttputil.h"
#include "llpounceable.h"
+#include "llproxy.h"
+#include "llrand.h"
// Constants
//const char* MESSAGE_LOG_FILENAME = "message.log";
@@ -173,7 +176,7 @@ void LLMessageSystem::init()
mTotalBytesIn = 0;
mTotalBytesOut = 0;
- mDroppedPackets = 0; // total dropped packets in
+ mLostPackets = 0; // total lost packets out
mResentPackets = 0; // total resent packets out
mFailedResendPackets = 0; // total resend failure packets out
mOffCircuitPackets = 0; // total # of off-circuit packets rejected
@@ -184,6 +187,13 @@ void LLMessageSystem::init()
mIncomingCompressedSize = 0;
mCurrentRecvPacketID = 0;
+ mActualBytesIn = 0;
+ mActualBytesOut = 0;
+ mDropPercentage = 0.0f;
+ mPacketsToDrop = 0;
+ mNumDroppedPackets = 0;
+ mNumDroppedPacketsTotal = 0;
+
mMessageFileVersionNumber = 0.f;
mTimingCallback = NULL;
@@ -508,18 +518,17 @@ bool LLMessageSystem::checkMessages(LockMessageChecker&, S64 frame_count )
bool recv_reliable = false;
bool recv_resent = false;
- S32 acks = 0;
+ S32 num_acks = 0;
S32 true_rcv_size = 0;
+ bool recv_packet_id_checked = false;
U8* buffer = mTrueReceiveBuffer;
- mTrueReceiveSize = mPacketRing.receivePacket(mSocket, (char *)mTrueReceiveBuffer);
+ mTrueReceiveSize = receivePacketOrDrop((char *)mTrueReceiveBuffer, recv_packet_id_checked);
// If you want to dump all received packets into SecondLife.log, uncomment this
//dumpPacketToLog();
receive_size = mTrueReceiveSize;
- mLastSender = mPacketRing.getLastSender();
- mLastReceivingIF = mPacketRing.getLastReceivingInterface();
if (receive_size < (S32) LL_MINIMUM_VALID_PACKET_SIZE)
{
@@ -535,24 +544,23 @@ bool LLMessageSystem::checkMessages(LockMessageChecker&, S64 frame_count )
}
else
{
- LLHost host;
- LLCircuitData* cdp;
-
- // note if packet acks are appended.
+ // handle any packet ACKs (for outbound messages) found at tail of inbound message
if(buffer[0] & LL_ACK_FLAG)
{
- acks += buffer[--receive_size];
+ // Note: these ACKs may have already been handled if this was a buffered message
+ // but it doesn't hurt to handle them again.
+ num_acks += buffer[--receive_size];
true_rcv_size = receive_size;
- if(receive_size >= ((S32)(acks * sizeof(TPACKETID) + LL_MINIMUM_VALID_PACKET_SIZE)))
+ if(receive_size >= ((S32)(num_acks * sizeof(TPACKETID) + LL_MINIMUM_VALID_PACKET_SIZE)))
{
- receive_size -= acks * sizeof(TPACKETID);
+ receive_size -= num_acks * sizeof(TPACKETID);
}
else
{
// mal-formed packet. ignore it and continue with
// the next one
LL_WARNS("Messaging") << "Malformed packet received. Packet size "
- << receive_size << " with invalid no. of acks " << acks
+ << receive_size << " with invalid no. of acks " << num_acks
<< LL_ENDL;
valid_packet = false;
continue;
@@ -562,20 +570,20 @@ bool LLMessageSystem::checkMessages(LockMessageChecker&, S64 frame_count )
// process the message as normal
mIncomingCompressedSize = zeroCodeExpand(&buffer, &receive_size);
mCurrentRecvPacketID = ntohl(*((U32*)(&buffer[1])));
- host = getSender();
+ LLHost host = getSender();
const bool resetPacketId = true;
- cdp = findCircuit(host, resetPacketId);
+ LLCircuitData* cdp = findCircuit(host, resetPacketId);
// At this point, cdp is now a pointer to the circuit that
// this message came in on if it's valid, and NULL if the
// circuit was bogus.
- if(cdp && (acks > 0) && ((S32)(acks * sizeof(TPACKETID)) < (true_rcv_size)))
+ if(cdp && (num_acks > 0) && ((S32)(num_acks * sizeof(TPACKETID)) < (true_rcv_size)))
{
TPACKETID packet_id;
U32 mem_id=0;
- for(S32 i = 0; i < acks; ++i)
+ for(S32 i = 0; i < num_acks; ++i)
{
true_rcv_size -= sizeof(TPACKETID);
memcpy(&mem_id, &mTrueReceiveBuffer[true_rcv_size], /* Flawfinder: ignore*/
@@ -630,7 +638,7 @@ bool LLMessageSystem::checkMessages(LockMessageChecker&, S64 frame_count )
str << tbuf << "(unknown)"
<< (recv_reliable ? " reliable" : "")
<< " resent "
- << ((acks > 0) ? "acks" : "")
+ << ((num_acks > 0) ? "acks" : "")
<< " DISCARD DUPLICATE";
LL_INFOS("Messaging") << str.str() << LL_ENDL;
}
@@ -680,7 +688,7 @@ bool LLMessageSystem::checkMessages(LockMessageChecker&, S64 frame_count )
if ( valid_packet )
{
- logValidMsg(cdp, host, recv_reliable, recv_resent, acks>0 );
+ logValidMsg(cdp, host, recv_reliable, recv_resent, num_acks>0, recv_packet_id_checked );
valid_packet = mTemplateMessageReader->readMessage(buffer, host);
}
@@ -724,7 +732,7 @@ bool LLMessageSystem::checkMessages(LockMessageChecker&, S64 frame_count )
// Check to see if we need to print debug info
if ((mt_sec - mCircuitPrintTime) > mCircuitPrintFreq)
{
- mPacketRing.dumpPacketRingStats();
+ dumpPacketRingStats();
dumpCircuitInfo();
mCircuitPrintTime = mt_sec;
}
@@ -749,6 +757,10 @@ S32 LLMessageSystem::getReceiveBytes() const
}
}
+F32 LLMessageSystem::getBufferLoadRate() const
+{
+ return llmax(mHighPriorityInbound.getBufferLoadRate(), mLowPriorityInbound.getBufferLoadRate());
+}
void LLMessageSystem::processAcks(LockMessageChecker&, F32 collect_time)
{
@@ -822,7 +834,300 @@ void LLMessageSystem::processAcks(LockMessageChecker&, F32 collect_time)
S32 LLMessageSystem::drainUdpSocket()
{
- return mPacketRing.drainSocket(mSocket);
+ S32 packet_size = 1;
+ S32 num_loops = 0;
+ S32 old_num_buffered_packets = getNumBufferedPackets();
+ while (packet_size > 0)
+ {
+ packet_size = bufferInboundPacket();
+ ++num_loops;
+ }
+ S32 num_dropped_packets = (num_loops - 1 + old_num_buffered_packets) - getNumBufferedPackets();
+ if (num_dropped_packets > 0)
+ {
+ mNumDroppedPackets += num_dropped_packets;
+ }
+ return getNumBufferedPackets();
+}
+
+bool LLMessageSystem::computeDrop()
+{
+ bool drop = (mDropPercentage > 0.0f && (ll_frand(100.f) < mDropPercentage));
+ if (drop)
+ {
+ ++mPacketsToDrop;
+ }
+ if (mPacketsToDrop > 0)
+ {
+ --mPacketsToDrop;
+ drop = true;
+ }
+ return drop;
+}
+
+bool LLMessageSystem::isHighPriorityMessage(const LLPacketBuffer& pkt) const
+{
+ S32 size = pkt.getSize();
+
+ // avoid stepping out of bounds
+ const S32 MIN_VALID_PACKET_SIZE = LL_PACKET_ID_SIZE + 4;
+ if (size < MIN_VALID_PACKET_SIZE)
+ {
+ return false;
+ }
+
+ // We want to prioritize crucial messages used to establish viewer <--> simulator connection,
+ // which are all low-frequency. A simple approximation is to just prioritize all non high-
+ // frequency messages.
+ //
+ // High frequency messages use a single byte for message_id whereas medium- and low-
+ // frequency messages have 255 at the first byte (which is after the LL_PACKET_ID_SIZE
+ // bytes of packet_id).
+ const U8* header = (const U8*)pkt.getData() + LL_PACKET_ID_SIZE;
+ if (header[0] != 255)
+ {
+ // high-frequency message
+ return false;
+ }
+
+ // BUG: The low-frequency AvatarAppearance message will be ignored if its agent is unknown
+ // and the agent is created upon receipt of its first high-frequency ObjectUpdate message.
+ // This race condition will be exacerbated by our default prioritization strategy.
+ //
+ // WORKAROUND: All middle- and low-frequency messages are high-priority except AvatarAppearance
+ //
+ // AvatarAppearance is "Low 158" which means it is stored in four bytes: 0xff 0xff 0x00 0x9E
+ // the last two bytes represent 158 in a BigEndian U16
+ return header[1] != 255 && header[2] != 0 && header[3] != 158;
+}
+
+void LLMessageSystem::dropPackets(U32 num_to_drop)
+{
+ mPacketsToDrop += num_to_drop;
+}
+
+void LLMessageSystem::setDropPercentage(F32 percent_to_drop)
+{
+ mDropPercentage = percent_to_drop;
+}
+
+S32 LLMessageSystem::receivePacketOrDrop(char* datap, bool& packet_id_already_checked)
+{
+ packet_id_already_checked = false;
+
+ if (getNumBufferedPackets() > 0)
+ {
+ LLHost invalid_host;
+ LLPacketBuffer pkt(invalid_host, nullptr, 0);
+ if (!mHighPriorityInbound.popPacket(pkt))
+ {
+ mLowPriorityInbound.popPacket(pkt);
+ }
+
+ S32 packet_size = pkt.getSize();
+ mLastSender = pkt.getHost();
+ mLastReceivingIF = pkt.getReceivingInterface();
+ packet_id_already_checked = pkt.getPacketIDChecked();
+
+ if (packet_size > 0)
+ {
+ memcpy(datap, pkt.getData(), packet_size);
+ }
+ return packet_size;
+ }
+
+ // Read directly from the socket. checkPacketInID() has not run yet for
+ // this packet.
+ bool drop = computeDrop();
+ S32 packet_size = 0;
+ if (LLProxy::isSOCKSProxyEnabled())
+ {
+ char buffer[NET_BUFFER_SIZE + SOCKS_HEADER_SIZE]; /* Flawfinder ignore */
+ packet_size = receive_packet(mSocket, buffer);
+ if (packet_size > 0)
+ {
+ mActualBytesIn += packet_size;
+ }
+ if (packet_size > SOCKS_HEADER_SIZE)
+ {
+ if (drop)
+ {
+ packet_size = 0;
+ }
+ else
+ {
+ // *FIX We are assuming ATYP is 0x01 (IPv4), not 0x03 (hostname) or 0x04 (IPv6)
+ packet_size -= SOCKS_HEADER_SIZE;
+ memcpy(datap, buffer + SOCKS_HEADER_SIZE, packet_size);
+ proxywrap_t* header = static_cast<proxywrap_t*>(static_cast<void*>(buffer));
+ mLastSender.setAddress(header->addr);
+ mLastSender.setPort(ntohs(header->port));
+ mLastReceivingIF = ::get_receiving_interface();
+ }
+ }
+ else
+ {
+ packet_size = 0;
+ }
+ }
+ else
+ {
+ packet_size = receive_packet(mSocket, datap);
+ if (packet_size > 0)
+ {
+ mActualBytesIn += packet_size;
+ if (drop)
+ {
+ packet_size = 0;
+ }
+ else
+ {
+ mLastSender = ::get_sender();
+ mLastReceivingIF = ::get_receiving_interface();
+ }
+ }
+ }
+ return packet_size;
+}
+
+S32 LLMessageSystem::bufferInboundPacket()
+{
+ LLHost invalid_host;
+ LLPacketBuffer pkt(invalid_host, nullptr, 0);
+ S32 packet_size = 0;
+
+ if (LLProxy::isSOCKSProxyEnabled())
+ {
+ char buffer[NET_BUFFER_SIZE + SOCKS_HEADER_SIZE]; /* Flawfinder ignore */
+ packet_size = receive_packet(mSocket, buffer);
+ if (packet_size > 0)
+ {
+ mActualBytesIn += packet_size;
+ if (packet_size > SOCKS_HEADER_SIZE)
+ {
+ // *FIX We are assuming ATYP is 0x01 (IPv4), not 0x03 (hostname) or 0x04 (IPv6)
+ proxywrap_t* header = static_cast<proxywrap_t*>(static_cast<void*>(buffer));
+ LLHost sender;
+ sender.setAddress(header->addr);
+ sender.setPort(ntohs(header->port));
+ packet_size -= SOCKS_HEADER_SIZE;
+ pkt.init(buffer + SOCKS_HEADER_SIZE, packet_size, sender);
+ }
+ else
+ {
+ packet_size = 0;
+ }
+ }
+ }
+ else
+ {
+ pkt.init(mSocket);
+ packet_size = pkt.getSize();
+ if (packet_size > 0)
+ {
+ mActualBytesIn += packet_size;
+ }
+ }
+
+ if (packet_size >= (S32)LL_MINIMUM_VALID_PACKET_SIZE && !computeDrop())
+ {
+ const char* data = pkt.getData();
+ LLCircuitData* cdp = mCircuitInfo.findCircuit(pkt.getHost());
+ TPACKETID recv_packet_id = ntohl(*((U32*)(&data[1])));
+
+ // Harvest piggybacked ACKs for outbound messages from the packet tail of this inbound message
+ if (cdp && (data[0] & LL_ACK_FLAG))
+ {
+ U8 num_acks = (U8)data[packet_size - 1];
+ S32 true_rcv_size = packet_size - 1;
+ if (true_rcv_size >= (S32)(num_acks * sizeof(TPACKETID) + LL_MINIMUM_VALID_PACKET_SIZE))
+ {
+ TPACKETID ack_id;
+ U32 mem_id = 0;
+ for (S32 i = 0; i < num_acks; ++i)
+ {
+ true_rcv_size -= sizeof(TPACKETID);
+ memcpy(&mem_id, &data[true_rcv_size], sizeof(TPACKETID)); /* Flawfinder: ignore */
+ ack_id = ntohl(mem_id);
+ cdp->ackReliablePacket(ack_id);
+ }
+ if (!cdp->getUnackedPacketCount())
+ {
+ mCircuitInfo.mUnackedCircuitMap.erase(cdp->mHost);
+ }
+ }
+ }
+
+ if (cdp)
+ {
+ // ACK inbound reliable packet ASAP
+ if ((data[0] & LL_RELIABLE_FLAG))
+ {
+ cdp->collectRAck(recv_packet_id);
+ }
+
+ // Check packet sequencing here, in true socket-arrival order, before
+ // this packet is sorted into the high/low priority inbound queue.
+ // Skip genuine duplicate resends, same as checkMessages()/logValidMsg()
+ // would do further downstream.
+ bool recv_resent = (data[0] & LL_RESENT_FLAG) != 0;
+ if (!recv_resent || !cdp->isDuplicateResend(recv_packet_id))
+ {
+ cdp->checkPacketInID(recv_packet_id, recv_resent);
+ pkt.setPacketIDChecked(true);
+ }
+ }
+
+ if (isHighPriorityMessage(pkt))
+ {
+ mHighPriorityInbound.pushPacket(pkt);
+ }
+ else
+ {
+ mLowPriorityInbound.pushPacket(pkt);
+ }
+ }
+
+ return packet_size;
+}
+
+bool LLMessageSystem::sendPacketToSocket(const char* datap, S32 data_size, LLHost host)
+{
+ mActualBytesOut += data_size;
+ if (!LLProxy::isSOCKSProxyEnabled())
+ {
+ return send_packet(mSocket, datap, data_size, host.getAddress(), host.getPort());
+ }
+
+ char headered_send_buffer[NET_BUFFER_SIZE + SOCKS_HEADER_SIZE];
+
+ proxywrap_t* socks_header = static_cast<proxywrap_t*>(static_cast<void*>(&headered_send_buffer));
+ socks_header->rsv = 0;
+ socks_header->addr = host.getAddress();
+ socks_header->port = htons(host.getPort());
+ socks_header->atype = ADDRESS_IPV4;
+ socks_header->frag = 0;
+
+ memcpy(headered_send_buffer + SOCKS_HEADER_SIZE, datap, data_size);
+
+ return send_packet(mSocket,
+ headered_send_buffer,
+ data_size + SOCKS_HEADER_SIZE,
+ LLProxy::getInstance()->getUDPProxy().getAddress(),
+ LLProxy::getInstance()->getUDPProxy().getPort());
+}
+
+void LLMessageSystem::dumpPacketRingStats()
+{
+ mNumDroppedPacketsTotal += mNumDroppedPackets;
+ LL_INFOS("Messaging") << "buffered_packets=" << getNumBufferedPackets()
+ << "buffered_bytes=" << (mHighPriorityInbound.getNumBufferedBytes() + mLowPriorityInbound.getNumBufferedBytes())
+ << "recently_dropped=" << mNumDroppedPackets
+ << "total_dropped=" << mNumDroppedPacketsTotal
+ << "dropped_percentage=" << mDropPercentage << "%"
+ << "bytes_IN=" << mActualBytesIn
+ << "bytes_OUT=" << mActualBytesOut << LL_ENDL;
+ mNumDroppedPackets = 0;
}
void LLMessageSystem::copyMessageReceivedToSend()
@@ -1277,7 +1582,7 @@ S32 LLMessageSystem::sendMessage(const LLHost &host)
}
bool success;
- success = mPacketRing.sendPacket(mSocket, (char *)buf_ptr, buffer_length, host);
+ success = sendPacketToSocket((char *)buf_ptr, buffer_length, host);
if (!success)
{
@@ -1401,7 +1706,13 @@ void LLMessageSystem::logTrustedMsgFromUntrustedCircuit( const LLHost& host )
}
}
-void LLMessageSystem::logValidMsg(LLCircuitData *cdp, const LLHost& host, bool recv_reliable, bool recv_resent, bool recv_acks )
+void LLMessageSystem::logValidMsg(
+ LLCircuitData *cdp,
+ const LLHost& host,
+ bool recv_reliable,
+ bool recv_resent,
+ bool recv_acks,
+ bool skip_packet_id_check )
{
if (mNumMessageCounts >= MAX_MESSAGE_COUNT_NUM)
{
@@ -1418,8 +1729,13 @@ void LLMessageSystem::logValidMsg(LLCircuitData *cdp, const LLHost& host, bool r
if (cdp)
{
- // update circuit packet ID tracking (missing/out of order packets)
- cdp->checkPacketInID( mCurrentRecvPacketID, recv_resent );
+ if (!skip_packet_id_check)
+ {
+ // update circuit packet ID tracking (missing/out of order packets)
+ // Already done in bufferInboundPacket(), in true socket-arrival
+ // order, if this packet came off the high/low priority queues.
+ cdp->checkPacketInID( mCurrentRecvPacketID, recv_resent );
+ }
cdp->addBytesIn( (S32Bytes)mTrueReceiveSize );
}
@@ -2376,7 +2692,7 @@ void dump_prehash_files()
{
U32 i;
std::string filename("../../indra/llmessage/message_prehash.h");
- LLFILE* fp = LLFile::fopen(filename, "w"); /* Flawfinder: ignore */
+ LLFILE* fp = LLFile::fopen(filename, LLFILE_MODE("w")); /* Flawfinder: ignore */
if (fp)
{
fprintf(
@@ -2407,7 +2723,7 @@ void dump_prehash_files()
fclose(fp);
}
filename = std::string("../../indra/llmessage/message_prehash.cpp");
- fp = LLFile::fopen(filename, "w"); /* Flawfinder: ignore */
+ fp = LLFile::fopen(filename, LLFILE_MODE("w")); /* Flawfinder: ignore */
if (fp)
{
fprintf(
@@ -2607,7 +2923,7 @@ void LLMessageSystem::summarizeLogs(std::ostream& str)
str << buffer << std::endl << std::endl;
buffer = llformat( "SendPacket failures: %20d", mSendPacketFailureCount);
str << buffer << std::endl;
- buffer = llformat( "Dropped packets: %20d", mDroppedPackets);
+ buffer = llformat( "Dropped packets: %20d", getTotalNumDroppedPackets());
str << buffer << std::endl;
buffer = llformat( "Resent packets: %20d", mResentPackets);
str << buffer << std::endl;
@@ -2639,6 +2955,7 @@ void LLMessageSystem::summarizeLogs(std::ostream& str)
void end_messaging_system(bool print_summary)
{
+ LL_PROFILE_ZONE_SCOPED;
gTransferManager.cleanup();
LLTransferTargetVFile::updateQueue(true); // shutdown LLTransferTargetVFile
if (gMessageSystem)
@@ -2744,85 +3061,6 @@ U32 LLMessageSystem::getListenPort( void ) const
return mPort;
}
-// TODO: babbage: remove this horror!
-S32 LLMessageSystem::zeroCodeAdjustCurrentSendTotal()
-{
- if(mMessageBuilder == mLLSDMessageBuilder)
- {
- // babbage: don't compress LLSD messages, so delta is 0
- return 0;
- }
-
- if (! mMessageBuilder->isBuilt())
- {
- mSendSize = mMessageBuilder->buildMessage(
- mSendBuffer,
- MAX_BUFFER_SIZE,
- 0);
- }
- // TODO: babbage: remove this horror
- mMessageBuilder->setBuilt(false);
-
- S32 count = mSendSize;
-
- S32 net_gain = 0;
- U8 num_zeroes = 0;
-
- U8 *inptr = (U8 *)mSendBuffer;
-
-// skip the packet id field
-
- for (U32 ii = 0; ii < LL_PACKET_ID_SIZE; ++ii)
- {
- count--;
- inptr++;
- }
-
-// don't actually build, just test
-
-// sequential zero bytes are encoded as 0 [U8 count]
-// with 0 0 [count] representing wrap (>256 zeroes)
-
- while (count--)
- {
- if (!(*inptr)) // in a zero count
- {
- if (num_zeroes)
- {
- if (++num_zeroes > 254)
- {
- num_zeroes = 0;
- }
- net_gain--; // subseqent zeroes save one
- }
- else
- {
- net_gain++; // starting a zero count adds one
- num_zeroes = 1;
- }
- inptr++;
- }
- else
- {
- if (num_zeroes)
- {
- num_zeroes = 0;
- }
- inptr++;
- }
- }
- if (net_gain < 0)
- {
- return net_gain;
- }
- else
- {
- return 0;
- }
-}
-
-
-
S32 LLMessageSystem::zeroCodeExpand(U8** data, S32* data_size)
{
if ((*data_size ) < LL_MINIMUM_VALID_PACKET_SIZE)
@@ -2843,74 +3081,18 @@ S32 LLMessageSystem::zeroCodeExpand(U8** data, S32* data_size)
mCompressedPacketsIn++;
mCompressedBytesIn += *data_size;
- *data[0] &= (~LL_ZERO_CODE_FLAG);
-
- S32 count = (*data_size);
-
- U8 *inptr = (U8 *)*data;
- U8 *outptr = (U8 *)mEncodedRecvBuffer;
-
-// skip the packet id field
-
- for (U32 ii = 0; ii < LL_PACKET_ID_SIZE; ++ii)
+ bool overflow = false;
+ U32 decoded_size = LLZeroCode::decode(*data, (U32)*data_size,
+ mEncodedRecvBuffer, sizeof(mEncodedRecvBuffer),
+ LL_PACKET_ID_SIZE, overflow);
+ if (overflow)
{
- count--;
- *outptr++ = *inptr++;
- }
-
-// reconstruct encoded packet, keeping track of net size gain
-
-// sequential zero bytes are encoded as 0 [U8 count]
-// with 0 0 [count] representing wrap (>256 zeroes)
-
- while (count--)
- {
- if (outptr > (&mEncodedRecvBuffer[MAX_BUFFER_SIZE-1]))
- {
- LL_WARNS("Messaging") << "attempt to write past reasonable encoded buffer size 1" << LL_ENDL;
- callExceptionFunc(MX_WROTE_PAST_BUFFER_SIZE);
- outptr = mEncodedRecvBuffer;
- break;
- }
- if (!((*outptr++ = *inptr++)))
- {
- while (((count--)) && (!(*inptr)))
- {
- *outptr++ = *inptr++;
- if (outptr > (&mEncodedRecvBuffer[MAX_BUFFER_SIZE-256]))
- {
- LL_WARNS("Messaging") << "attempt to write past reasonable encoded buffer size 2" << LL_ENDL;
- callExceptionFunc(MX_WROTE_PAST_BUFFER_SIZE);
- outptr = mEncodedRecvBuffer;
- count = -1;
- break;
- }
- memset(outptr,0,255);
- outptr += 255;
- }
-
- if (count < 0)
- {
- break;
- }
-
- else
- {
- if (outptr > (&mEncodedRecvBuffer[MAX_BUFFER_SIZE-(*inptr)]))
- {
- LL_WARNS("Messaging") << "attempt to write past reasonable encoded buffer size 3" << LL_ENDL;
- callExceptionFunc(MX_WROTE_PAST_BUFFER_SIZE);
- outptr = mEncodedRecvBuffer;
- }
- memset(outptr,0,(*inptr) - 1);
- outptr += ((*inptr) - 1);
- inptr++;
- }
- }
+ LL_WARNS("Messaging") << "attempt to write past reasonable encoded buffer size" << LL_ENDL;
+ callExceptionFunc(MX_WROTE_PAST_BUFFER_SIZE);
}
*data = mEncodedRecvBuffer;
- *data_size = (S32)(outptr - mEncodedRecvBuffer);
+ *data_size = (S32)decoded_size;
mUncompressedBytesIn += *data_size;
return(in_size);
@@ -3333,7 +3515,7 @@ void LLMessageSystem::establishBidirectionalTrust(const LLHost &host, S64 frame_
void LLMessageSystem::dumpPacketToLog()
{
- LL_WARNS("Messaging") << "Packet Dump from:" << mPacketRing.getLastSender() << LL_ENDL;
+ LL_WARNS("Messaging") << "Packet Dump from:" << mLastSender << LL_ENDL;
LL_WARNS("Messaging") << "Packet Size:" << mTrueReceiveSize << LL_ENDL;
char line_buffer[256]; /* Flawfinder: ignore */
S32 i;