summaryrefslogtreecommitdiff
path: root/indra/llmessage/lltemplatemessagereader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmessage/lltemplatemessagereader.cpp')
-rwxr-xr-x[-rw-r--r--]indra/llmessage/lltemplatemessagereader.cpp170
1 files changed, 83 insertions, 87 deletions
diff --git a/indra/llmessage/lltemplatemessagereader.cpp b/indra/llmessage/lltemplatemessagereader.cpp
index 6682575ca5..406afadd2f 100644..100755
--- a/indra/llmessage/lltemplatemessagereader.cpp
+++ b/indra/llmessage/lltemplatemessagereader.cpp
@@ -2,31 +2,25 @@
* @file lltemplatemessagereader.cpp
* @brief LLTemplateMessageReader class implementation.
*
- * $LicenseInfo:firstyear=2007&license=viewergpl$
- *
- * Copyright (c) 2007-2009, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -36,6 +30,7 @@
#include "llfasttimer.h"
#include "llmessagebuilder.h"
#include "llmessagetemplate.h"
+#include "llmath.h"
#include "llquaternion.h"
#include "message.h"
#include "u64.h"
@@ -73,13 +68,13 @@ void LLTemplateMessageReader::getData(const char *blockname, const char *varname
// is there a message ready to go?
if (mReceiveSize == -1)
{
- llerrs << "No message waiting for decode 2!" << llendl;
+ LL_ERRS() << "No message waiting for decode 2!" << LL_ENDL;
return;
}
if (!mCurrentRMessageData)
{
- llerrs << "Invalid mCurrentMessageData in getData!" << llendl;
+ LL_ERRS() << "Invalid mCurrentMessageData in getData!" << LL_ENDL;
return;
}
@@ -90,28 +85,30 @@ void LLTemplateMessageReader::getData(const char *blockname, const char *varname
if (iter == mCurrentRMessageData->mMemberBlocks.end())
{
- llerrs << "Block " << blockname << " #" << blocknum
- << " not in message " << mCurrentRMessageData->mName << llendl;
+ LL_ERRS() << "Block " << blockname << " #" << blocknum
+ << " not in message " << mCurrentRMessageData->mName << LL_ENDL;
return;
}
LLMsgBlkData *msg_block_data = iter->second;
- LLMsgVarData& vardata = msg_block_data->mMemberVarData[vnamep];
+ LLMsgBlkData::msg_var_data_map_t &var_data_map = msg_block_data->mMemberVarData;
- if (!vardata.getName())
+ if (var_data_map.find(vnamep) == var_data_map.end())
{
- llerrs << "Variable "<< vnamep << " not in message "
- << mCurrentRMessageData->mName<< " block " << bnamep << llendl;
+ LL_ERRS() << "Variable "<< vnamep << " not in message "
+ << mCurrentRMessageData->mName<< " block " << bnamep << LL_ENDL;
return;
}
+ LLMsgVarData& vardata = msg_block_data->mMemberVarData[vnamep];
+
if (size && size != vardata.getSize())
{
- llerrs << "Msg " << mCurrentRMessageData->mName
+ LL_ERRS() << "Msg " << mCurrentRMessageData->mName
<< " variable " << vnamep
<< " is size " << vardata.getSize()
<< " but copying into buffer of size " << size
- << llendl;
+ << LL_ENDL;
return;
}
@@ -141,11 +138,11 @@ void LLTemplateMessageReader::getData(const char *blockname, const char *varname
}
else
{
- llwarns << "Msg " << mCurrentRMessageData->mName
+ LL_WARNS() << "Msg " << mCurrentRMessageData->mName
<< " variable " << vnamep
<< " is size " << vardata.getSize()
<< " but truncated to max size of " << max_size
- << llendl;
+ << LL_ENDL;
memcpy(datap, vardata.getData(), max_size);
}
@@ -156,13 +153,13 @@ S32 LLTemplateMessageReader::getNumberOfBlocks(const char *blockname)
// is there a message ready to go?
if (mReceiveSize == -1)
{
- llerrs << "No message waiting for decode 3!" << llendl;
+ LL_ERRS() << "No message waiting for decode 3!" << LL_ENDL;
return -1;
}
if (!mCurrentRMessageData)
{
- llerrs << "Invalid mCurrentRMessageData in getData!" << llendl;
+ LL_ERRS() << "Invalid mCurrentRMessageData in getData!" << LL_ENDL;
return -1;
}
@@ -183,13 +180,13 @@ S32 LLTemplateMessageReader::getSize(const char *blockname, const char *varname)
// is there a message ready to go?
if (mReceiveSize == -1)
{ // This is a serious error - crash
- llerrs << "No message waiting for decode 4!" << llendl;
+ LL_ERRS() << "No message waiting for decode 4!" << LL_ENDL;
return LL_MESSAGE_ERROR;
}
if (!mCurrentRMessageData)
{ // This is a serious error - crash
- llerrs << "Invalid mCurrentRMessageData in getData!" << llendl;
+ LL_ERRS() << "Invalid mCurrentRMessageData in getData!" << LL_ENDL;
return LL_MESSAGE_ERROR;
}
@@ -199,8 +196,8 @@ S32 LLTemplateMessageReader::getSize(const char *blockname, const char *varname)
if (iter == mCurrentRMessageData->mMemberBlocks.end())
{ // don't crash
- llinfos << "Block " << bnamep << " not in message "
- << mCurrentRMessageData->mName << llendl;
+ LL_INFOS() << "Block " << bnamep << " not in message "
+ << mCurrentRMessageData->mName << LL_ENDL;
return LL_BLOCK_NOT_IN_MESSAGE;
}
@@ -211,15 +208,15 @@ S32 LLTemplateMessageReader::getSize(const char *blockname, const char *varname)
if (!vardata.getName())
{ // don't crash
- llinfos << "Variable " << varname << " not in message "
- << mCurrentRMessageData->mName << " block " << bnamep << llendl;
+ LL_INFOS() << "Variable " << varname << " not in message "
+ << mCurrentRMessageData->mName << " block " << bnamep << LL_ENDL;
return LL_VARIABLE_NOT_IN_BLOCK;
}
if (mCurrentRMessageTemplate->mMemberBlocks[bnamep]->mType != MBT_SINGLE)
{ // This is a serious error - crash
- llerrs << "Block " << bnamep << " isn't type MBT_SINGLE,"
- " use getSize with blocknum argument!" << llendl;
+ LL_ERRS() << "Block " << bnamep << " isn't type MBT_SINGLE,"
+ " use getSize with blocknum argument!" << LL_ENDL;
return LL_MESSAGE_ERROR;
}
@@ -231,13 +228,13 @@ S32 LLTemplateMessageReader::getSize(const char *blockname, S32 blocknum, const
// is there a message ready to go?
if (mReceiveSize == -1)
{ // This is a serious error - crash
- llerrs << "No message waiting for decode 5!" << llendl;
+ LL_ERRS() << "No message waiting for decode 5!" << LL_ENDL;
return LL_MESSAGE_ERROR;
}
if (!mCurrentRMessageData)
{ // This is a serious error - crash
- llerrs << "Invalid mCurrentRMessageData in getData!" << llendl;
+ LL_ERRS() << "Invalid mCurrentRMessageData in getData!" << LL_ENDL;
return LL_MESSAGE_ERROR;
}
@@ -248,8 +245,8 @@ S32 LLTemplateMessageReader::getSize(const char *blockname, S32 blocknum, const
if (iter == mCurrentRMessageData->mMemberBlocks.end())
{ // don't crash
- llinfos << "Block " << bnamep << " not in message "
- << mCurrentRMessageData->mName << llendl;
+ LL_INFOS() << "Block " << bnamep << " not in message "
+ << mCurrentRMessageData->mName << LL_ENDL;
return LL_BLOCK_NOT_IN_MESSAGE;
}
@@ -258,8 +255,8 @@ S32 LLTemplateMessageReader::getSize(const char *blockname, S32 blocknum, const
if (!vardata.getName())
{ // don't crash
- llinfos << "Variable " << vnamep << " not in message "
- << mCurrentRMessageData->mName << " block " << bnamep << llendl;
+ LL_INFOS() << "Variable " << vnamep << " not in message "
+ << mCurrentRMessageData->mName << " block " << bnamep << LL_ENDL;
return LL_VARIABLE_NOT_IN_BLOCK;
}
@@ -331,8 +328,8 @@ void LLTemplateMessageReader::getF32(const char *block, const char *var,
if( !llfinite( d ) )
{
- llwarns << "non-finite in getF32Fast " << block << " " << var
- << llendl;
+ LL_WARNS() << "non-finite in getF32Fast " << block << " " << var
+ << LL_ENDL;
d = 0;
}
}
@@ -344,8 +341,8 @@ void LLTemplateMessageReader::getF64(const char *block, const char *var,
if( !llfinite( d ) )
{
- llwarns << "non-finite in getF64Fast " << block << " " << var
- << llendl;
+ LL_WARNS() << "non-finite in getF64Fast " << block << " " << var
+ << LL_ENDL;
d = 0;
}
}
@@ -357,8 +354,8 @@ void LLTemplateMessageReader::getVector3(const char *block, const char *var,
if( !v.isFinite() )
{
- llwarns << "non-finite in getVector3Fast " << block << " "
- << var << llendl;
+ LL_WARNS() << "non-finite in getVector3Fast " << block << " "
+ << var << LL_ENDL;
v.zeroVec();
}
}
@@ -370,8 +367,8 @@ void LLTemplateMessageReader::getVector4(const char *block, const char *var,
if( !v.isFinite() )
{
- llwarns << "non-finite in getVector4Fast " << block << " "
- << var << llendl;
+ LL_WARNS() << "non-finite in getVector4Fast " << block << " "
+ << var << LL_ENDL;
v.zeroVec();
}
}
@@ -383,8 +380,8 @@ void LLTemplateMessageReader::getVector3d(const char *block, const char *var,
if( !v.isFinite() )
{
- llwarns << "non-finite in getVector3dFast " << block << " "
- << var << llendl;
+ LL_WARNS() << "non-finite in getVector3dFast " << block << " "
+ << var << LL_ENDL;
v.zeroVec();
}
@@ -401,8 +398,8 @@ void LLTemplateMessageReader::getQuat(const char *block, const char *var,
}
else
{
- llwarns << "non-finite in getQuatFast " << block << " " << var
- << llendl;
+ LL_WARNS() << "non-finite in getQuatFast " << block << " " << var
+ << LL_ENDL;
q.loadIdentity();
}
}
@@ -433,10 +430,9 @@ inline void LLTemplateMessageReader::getString(const char *block, const char *va
inline void LLTemplateMessageReader::getString(const char *block, const char *var, std::string& outstr, S32 blocknum )
{
- char s[MTUBYTES];
- s[0] = '\0';
+ char s[MTUBYTES + 1]= {0}; // every element is initialized with 0
getData(block, var, s, 0, blocknum, MTUBYTES);
- s[MTUBYTES - 1] = '\0';
+ s[MTUBYTES] = '\0';
outstr = s;
}
@@ -456,7 +452,7 @@ BOOL LLTemplateMessageReader::decodeTemplate(
// is there a message ready to go?
if (buffer_size <= 0)
{
- llwarns << "No message waiting for decode!" << llendl;
+ LL_WARNS() << "No message waiting for decode!" << LL_ENDL;
return(FALSE);
}
@@ -491,8 +487,8 @@ BOOL LLTemplateMessageReader::decodeTemplate(
}
else // bogus packet received (too short)
{
- llwarns << "Packet with unusable length received (too short): "
- << buffer_size << llendl;
+ LL_WARNS() << "Packet with unusable length received (too short): "
+ << buffer_size << LL_ENDL;
return(FALSE);
}
@@ -503,8 +499,8 @@ BOOL LLTemplateMessageReader::decodeTemplate(
}
else
{
- llwarns << "Message #" << std::hex << num << std::dec
- << " received but not registered!" << llendl;
+ LL_WARNS() << "Message #" << std::hex << num << std::dec
+ << " received but not registered!" << LL_ENDL;
gMessageSystem->callExceptionFunc(MX_UNREGISTERED_MESSAGE);
return(FALSE);
}
@@ -515,23 +511,23 @@ BOOL LLTemplateMessageReader::decodeTemplate(
void LLTemplateMessageReader::logRanOffEndOfPacket( const LLHost& host, const S32 where, const S32 wanted )
{
// we've run off the end of the packet!
- llwarns << "Ran off end of packet " << mCurrentRMessageTemplate->mName
+ LL_WARNS() << "Ran off end of packet " << mCurrentRMessageTemplate->mName
// << " with id " << mCurrentRecvPacketID
<< " from " << host
<< " trying to read " << wanted
<< " bytes at position " << where
<< " going past packet end at " << mReceiveSize
- << llendl;
+ << LL_ENDL;
if(gMessageSystem->mVerboseLog)
{
- llinfos << "MSG: -> " << host << "\tREAD PAST END:\t"
+ LL_INFOS() << "MSG: -> " << host << "\tREAD PAST END:\t"
// << mCurrentRecvPacketID << " "
- << getMessageName() << llendl;
+ << getMessageName() << LL_ENDL;
}
gMessageSystem->callExceptionFunc(MX_RAN_OFF_END_OF_PACKET);
}
-static LLFastTimer::DeclareTimer FTM_PROCESS_MESSAGES("Process Messages");
+static LLTrace::BlockTimerStatHandle FTM_PROCESS_MESSAGES("Process Messages");
// decode a given message
BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender )
@@ -592,7 +588,7 @@ BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender
}
else
{
- llerrs << "Unknown block type" << llendl;
+ LL_ERRS() << "Unknown block type" << LL_ENDL;
return FALSE;
}
@@ -659,7 +655,7 @@ BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender
htonmemcpy(&tsize, &buffer[decode_pos], MVT_U32, 4);
break;
default:
- llerrs << "Attempting to read variable field with unknown size of " << data_size << llendl;
+ LL_ERRS() << "Attempting to read variable field with unknown size of " << data_size << LL_ENDL;
break;
}
}
@@ -698,7 +694,7 @@ BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender
if (mCurrentRMessageData->mMemberBlocks.empty()
&& !mCurrentRMessageTemplate->mMemberBlocks.empty())
{
- lldebugs << "Empty message '" << mCurrentRMessageTemplate->mName << "' (no blocks)" << llendl;
+ LL_DEBUGS() << "Empty message '" << mCurrentRMessageTemplate->mName << "' (no blocks)" << LL_ENDL;
return FALSE;
}
@@ -711,10 +707,10 @@ BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender
}
{
- LLFastTimer t(FTM_PROCESS_MESSAGES);
+ LL_RECORD_BLOCK_TIME(FTM_PROCESS_MESSAGES);
if( !mCurrentRMessageTemplate->callHandlerFunc(gMessageSystem) )
{
- llwarns << "Message from " << sender << " with no handler function received: " << mCurrentRMessageTemplate->mName << llendl;
+ LL_WARNS() << "Message from " << sender << " with no handler function received: " << mCurrentRMessageTemplate->mName << LL_ENDL;
}
}
@@ -744,9 +740,9 @@ BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender
if(decode_time > LLMessageReader::getTimeDecodesSpamThreshold())
{
- lldebugs << "--------- Message " << mCurrentRMessageTemplate->mName << " decode took " << decode_time << " seconds. (" <<
+ LL_DEBUGS() << "--------- Message " << mCurrentRMessageTemplate->mName << " decode took " << decode_time << " seconds. (" <<
mCurrentRMessageTemplate->mMaxDecodeTimePerMsg << " max, " <<
- (mCurrentRMessageTemplate->mTotalDecodeTime / mCurrentRMessageTemplate->mTotalDecoded) << " avg)" << llendl;
+ (mCurrentRMessageTemplate->mTotalDecodeTime / mCurrentRMessageTemplate->mTotalDecoded) << " avg)" << LL_ENDL;
}
}
}
@@ -764,9 +760,9 @@ BOOL LLTemplateMessageReader::validateMessage(const U8* buffer,
if(valid)
{
mCurrentRMessageTemplate->mReceiveCount++;
- //lldebugs << "MessageRecvd:"
+ //LL_DEBUGS() << "MessageRecvd:"
// << mCurrentRMessageTemplate->mName
- // << " from " << sender << llendl;
+ // << " from " << sender << LL_ENDL;
}
if (valid && isBanned(trusted))
@@ -776,15 +772,15 @@ BOOL LLTemplateMessageReader::validateMessage(const U8* buffer,
<< getMessageName()
<< " from "
<< ((trusted) ? "trusted " : "untrusted ")
- << sender << llendl;
+ << sender << LL_ENDL;
valid = FALSE;
}
if(valid && isUdpBanned())
{
- llwarns << "Received UDP black listed message "
+ LL_WARNS() << "Received UDP black listed message "
<< getMessageName()
- << " from " << sender << llendl;
+ << " from " << sender << LL_ENDL;
valid = FALSE;
}
return valid;
@@ -801,7 +797,7 @@ const char* LLTemplateMessageReader::getMessageName() const
{
if (!mCurrentRMessageTemplate)
{
- llwarns << "no mCurrentRMessageTemplate" << llendl;
+ // no message currently being read
return "";
}
return mCurrentRMessageTemplate->mName;