aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/message.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/llmessage/message.cpp
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/llmessage/message.cpp')
-rw-r--r--linden/indra/llmessage/message.cpp172
1 files changed, 96 insertions, 76 deletions
diff --git a/linden/indra/llmessage/message.cpp b/linden/indra/llmessage/message.cpp
index f3aac29..27f9d12 100644
--- a/linden/indra/llmessage/message.cpp
+++ b/linden/indra/llmessage/message.cpp
@@ -46,9 +46,9 @@
46#include <sstream> 46#include <sstream>
47 47
48#include "llapr.h" 48#include "llapr.h"
49#include "apr-1/apr_portable.h" 49#include "apr_portable.h"
50#include "apr-1/apr_network_io.h" 50#include "apr_network_io.h"
51#include "apr-1/apr_poll.h" 51#include "apr_poll.h"
52 52
53// linden library headers 53// linden library headers
54#include "indra_constants.h" 54#include "indra_constants.h"
@@ -286,10 +286,11 @@ void LLMessageSystem::init()
286} 286}
287 287
288// Read file and build message templates 288// Read file and build message templates
289LLMessageSystem::LLMessageSystem(const char *filename, U32 port, 289LLMessageSystem::LLMessageSystem(const std::string& filename, U32 port,
290 S32 version_major, 290 S32 version_major,
291 S32 version_minor, 291 S32 version_minor,
292 S32 version_patch) 292 S32 version_patch,
293 bool failure_is_fatal)
293{ 294{
294 init(); 295 init();
295 296
@@ -306,7 +307,7 @@ LLMessageSystem::LLMessageSystem(const char *filename, U32 port,
306 307
307 mCircuitPrintFreq = 60.f; // seconds 308 mCircuitPrintFreq = 60.f; // seconds
308 309
309 loadTemplateFile(filename); 310 loadTemplateFile(filename, failure_is_fatal);
310 311
311 mTemplateMessageBuilder = new LLTemplateMessageBuilder(mMessageTemplates); 312 mTemplateMessageBuilder = new LLTemplateMessageBuilder(mMessageTemplates);
312 mLLSDMessageBuilder = new LLSDMessageBuilder(); 313 mLLSDMessageBuilder = new LLSDMessageBuilder();
@@ -365,9 +366,9 @@ LLMessageSystem::LLMessageSystem(const char *filename, U32 port,
365 366
366 367
367// Read file and build message templates 368// Read file and build message templates
368void LLMessageSystem::loadTemplateFile(const char* filename) 369void LLMessageSystem::loadTemplateFile(const std::string& filename, bool failure_is_fatal)
369{ 370{
370 if(!filename) 371 if(filename.empty())
371 { 372 {
372 LL_ERRS("Messaging") << "No template filename specified" << llendl; 373 LL_ERRS("Messaging") << "No template filename specified" << llendl;
373 mbError = TRUE; 374 mbError = TRUE;
@@ -377,7 +378,11 @@ void LLMessageSystem::loadTemplateFile(const char* filename)
377 std::string template_body; 378 std::string template_body;
378 if(!_read_file_into_string(template_body, filename)) 379 if(!_read_file_into_string(template_body, filename))
379 { 380 {
380 LL_WARNS("Messaging") << "Failed to open template: " << filename << llendl; 381 if (failure_is_fatal) {
382 LL_ERRS("Messaging") << "Failed to open template: " << filename << llendl;
383 } else {
384 LL_WARNS("Messaging") << "Failed to open template: " << filename << llendl;
385 }
381 mbError = TRUE; 386 mbError = TRUE;
382 return; 387 return;
383 } 388 }
@@ -686,9 +691,9 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count )
686 { 691 {
687 std::ostringstream str; 692 std::ostringstream str;
688 str << "MSG: <- " << host; 693 str << "MSG: <- " << host;
689 char buffer[MAX_STRING]; /* Flawfinder: ignore*/ 694 std::string tbuf;
690 snprintf(buffer, MAX_STRING, "\t%6d\t%6d\t%6d ", receive_size, (mIncomingCompressedSize ? mIncomingCompressedSize : receive_size), mCurrentRecvPacketID); /* Flawfinder: ignore */ 695 tbuf = llformat( "\t%6d\t%6d\t%6d ", receive_size, (mIncomingCompressedSize ? mIncomingCompressedSize : receive_size), mCurrentRecvPacketID);
691 str << buffer << "(unknown)" 696 str << tbuf << "(unknown)"
692 << (recv_reliable ? " reliable" : "") 697 << (recv_reliable ? " reliable" : "")
693 << " resent " 698 << " resent "
694 << ((acks > 0) ? "acks" : "") 699 << ((acks > 0) ? "acks" : "")
@@ -816,10 +821,9 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count )
816 821
817 LLMsgBlkData *msg_block_data = mCurrentRMessageData->mMemberBlocks[bnamep]; 822 LLMsgBlkData *msg_block_data = mCurrentRMessageData->mMemberBlocks[bnamep];
818 823
819 char errmsg[1024];
820 if (!msg_block_data) 824 if (!msg_block_data)
821 { 825 {
822 sprintf(errmsg, "Block %s #%d not in message %s", block_name, blocknum, mCurrentRMessageData->mName); 826 std::string errmsg = llformat("Block %s #%d not in message %s", block_name, blocknum, mCurrentRMessageData->mName);
823 LL_ERRS("Messaging") << errmsg << llendl; 827 LL_ERRS("Messaging") << errmsg << llendl;
824 } 828 }
825 829
@@ -827,7 +831,7 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count )
827 831
828 if (!vardata.getName()) 832 if (!vardata.getName())
829 { 833 {
830 sprintf(errmsg, "Variable %s not in message %s block %s", vnamep, mCurrentRMessageData->mName, bnamep); 834 std::string errmsg = llformat("Variable %s not in message %s block %s", vnamep, mCurrentRMessageData->mName, bnamep);
831 LL_ERRS("Messaging") << errmsg << llendl; 835 LL_ERRS("Messaging") << errmsg << llendl;
832 } 836 }
833 837
@@ -1378,8 +1382,8 @@ S32 LLMessageSystem::sendMessage(const LLHost &host)
1378 { 1382 {
1379 std::ostringstream str; 1383 std::ostringstream str;
1380 str << "MSG: -> " << host; 1384 str << "MSG: -> " << host;
1381 char buffer[MAX_STRING]; /* Flawfinder: ignore */ 1385 std::string buffer;
1382 snprintf(buffer, MAX_STRING, "\t%6d\t%6d\t%6d ", mSendSize, buffer_length, cdp->getPacketOutID()); /* Flawfinder: ignore */ 1386 buffer = llformat( "\t%6d\t%6d\t%6d ", mSendSize, buffer_length, cdp->getPacketOutID());
1383 str << buffer 1387 str << buffer
1384 << mMessageBuilder->getMessageName() 1388 << mMessageBuilder->getMessageName()
1385 << (mSendReliable ? " reliable " : ""); 1389 << (mSendReliable ? " reliable " : "");
@@ -1407,8 +1411,8 @@ void LLMessageSystem::logMsgFromInvalidCircuit( const LLHost& host, BOOL recv_re
1407 { 1411 {
1408 std::ostringstream str; 1412 std::ostringstream str;
1409 str << "MSG: <- " << host; 1413 str << "MSG: <- " << host;
1410 char buffer[MAX_STRING]; /* Flawfinder: ignore */ 1414 std::string buffer;
1411 snprintf(buffer, MAX_STRING, "\t%6d\t%6d\t%6d ", mMessageReader->getMessageSize(), (mIncomingCompressedSize ? mIncomingCompressedSize: mMessageReader->getMessageSize()), mCurrentRecvPacketID); /* Flawfinder: ignore */ 1415 buffer = llformat( "\t%6d\t%6d\t%6d ", mMessageReader->getMessageSize(), (mIncomingCompressedSize ? mIncomingCompressedSize: mMessageReader->getMessageSize()), mCurrentRecvPacketID);
1412 str << buffer 1416 str << buffer
1413 << nullToEmpty(mMessageReader->getMessageName()) 1417 << nullToEmpty(mMessageReader->getMessageName())
1414 << (recv_reliable ? " reliable" : "") 1418 << (recv_reliable ? " reliable" : "")
@@ -1512,8 +1516,8 @@ void LLMessageSystem::logValidMsg(LLCircuitData *cdp, const LLHost& host, BOOL r
1512 { 1516 {
1513 std::ostringstream str; 1517 std::ostringstream str;
1514 str << "MSG: <- " << host; 1518 str << "MSG: <- " << host;
1515 char buffer[MAX_STRING]; /* Flawfinder: ignore */ 1519 std::string buffer;
1516 snprintf(buffer, MAX_STRING, "\t%6d\t%6d\t%6d ", mMessageReader->getMessageSize(), (mIncomingCompressedSize ? mIncomingCompressedSize : mMessageReader->getMessageSize()), mCurrentRecvPacketID); /* Flawfinder: ignore */ 1520 buffer = llformat( "\t%6d\t%6d\t%6d ", mMessageReader->getMessageSize(), (mIncomingCompressedSize ? mIncomingCompressedSize : mMessageReader->getMessageSize()), mCurrentRecvPacketID);
1517 str << buffer 1521 str << buffer
1518 << nullToEmpty(mMessageReader->getMessageName()) 1522 << nullToEmpty(mMessageReader->getMessageName())
1519 << (recv_reliable ? " reliable" : "") 1523 << (recv_reliable ? " reliable" : "")
@@ -2086,20 +2090,18 @@ void LLMessageSystem::processUseCircuitCode(LLMessageSystem* msg,
2086// static 2090// static
2087void LLMessageSystem::processError(LLMessageSystem* msg, void**) 2091void LLMessageSystem::processError(LLMessageSystem* msg, void**)
2088{ 2092{
2089 char buffer[MTUBYTES];
2090 S32 error_code = 0; 2093 S32 error_code = 0;
2091 msg->getS32("Data", "Code", error_code); 2094 msg->getS32("Data", "Code", error_code);
2092 std::string error_token; 2095 std::string error_token;
2093 msg->getString("Data", "Token", MTUBYTES, buffer); 2096 msg->getString("Data", "Token", error_token);
2094 error_token.assign(buffer); 2097
2095 LLUUID error_id; 2098 LLUUID error_id;
2096 msg->getUUID("Data", "ID", error_id); 2099 msg->getUUID("Data", "ID", error_id);
2097 std::string error_system; 2100 std::string error_system;
2098 msg->getString("Data", "System", MTUBYTES, buffer); 2101 msg->getString("Data", "System", error_system);
2099 error_system.assign(buffer); 2102
2100 std::string error_message; 2103 std::string error_message;
2101 msg->getString("Data", "Message", MTUBYTES, buffer); 2104 msg->getString("Data", "Message", error_message);
2102 error_message.assign(buffer);
2103 2105
2104 LL_WARNS("Messaging") << "Message error from " << msg->getSender() << " - " 2106 LL_WARNS("Messaging") << "Message error from " << msg->getSender() << " - "
2105 << error_code << " " << error_token << " " << error_id << " \"" 2107 << error_code << " " << error_token << " " << error_id << " \""
@@ -2415,7 +2417,8 @@ void process_deny_trusted_circuit(LLMessageSystem *msg, void **)
2415void dump_prehash_files() 2417void dump_prehash_files()
2416{ 2418{
2417 U32 i; 2419 U32 i;
2418 LLFILE* fp = LLFile::fopen("../../indra/llmessage/message_prehash.h", "w"); /* Flawfinder: ignore */ 2420 std::string filename("../../indra/llmessage/message_prehash.h");
2421 LLFILE* fp = LLFile::fopen(filename, "w"); /* Flawfinder: ignore */
2419 if (fp) 2422 if (fp)
2420 { 2423 {
2421 fprintf( 2424 fprintf(
@@ -2445,7 +2448,8 @@ void dump_prehash_files()
2445 fprintf(fp, "\n\n#endif\n"); 2448 fprintf(fp, "\n\n#endif\n");
2446 fclose(fp); 2449 fclose(fp);
2447 } 2450 }
2448 fp = LLFile::fopen("../../indra/llmessage/message_prehash.cpp", "w"); /* Flawfinder: ignore */ 2451 filename = std::string("../../indra/llmessage/message_prehash.cpp");
2452 fp = LLFile::fopen(filename, "w"); /* Flawfinder: ignore */
2449 if (fp) 2453 if (fp)
2450 { 2454 {
2451 fprintf( 2455 fprintf(
@@ -2475,22 +2479,24 @@ void dump_prehash_files()
2475 } 2479 }
2476} 2480}
2477 2481
2478BOOL start_messaging_system( 2482bool start_messaging_system(
2479 const std::string& template_name, 2483 const std::string& template_name,
2480 U32 port, 2484 U32 port,
2481 S32 version_major, 2485 S32 version_major,
2482 S32 version_minor, 2486 S32 version_minor,
2483 S32 version_patch, 2487 S32 version_patch,
2484 BOOL b_dump_prehash_file, 2488 bool b_dump_prehash_file,
2485 const std::string& secret, 2489 const std::string& secret,
2486 const LLUseCircuitCodeResponder* responder) 2490 const LLUseCircuitCodeResponder* responder,
2491 bool failure_is_fatal)
2487{ 2492{
2488 gMessageSystem = new LLMessageSystem( 2493 gMessageSystem = new LLMessageSystem(
2489 template_name.c_str(), 2494 template_name,
2490 port, 2495 port,
2491 version_major, 2496 version_major,
2492 version_minor, 2497 version_minor,
2493 version_patch); 2498 version_patch,
2499 failure_is_fatal);
2494 g_shared_secret.assign(secret); 2500 g_shared_secret.assign(secret);
2495 2501
2496 if (!gMessageSystem) 2502 if (!gMessageSystem)
@@ -2579,79 +2585,79 @@ void LLMessageSystem::stopLogging()
2579 2585
2580void LLMessageSystem::summarizeLogs(std::ostream& str) 2586void LLMessageSystem::summarizeLogs(std::ostream& str)
2581{ 2587{
2582 char buffer[MAX_STRING]; /* Flawfinder: ignore */ 2588 std::string buffer;
2583 char tmp_str[MAX_STRING]; /* Flawfinder: ignore */ 2589 std::string tmp_str;
2584 F32 run_time = mMessageSystemTimer.getElapsedTimeF32(); 2590 F32 run_time = mMessageSystemTimer.getElapsedTimeF32();
2585 str << "START MESSAGE LOG SUMMARY" << std::endl; 2591 str << "START MESSAGE LOG SUMMARY" << std::endl;
2586 snprintf(buffer, MAX_STRING, "Run time: %12.3f seconds", run_time); /* Flawfinder: ignore */ 2592 buffer = llformat( "Run time: %12.3f seconds", run_time);
2587 2593
2588 // Incoming 2594 // Incoming
2589 str << buffer << std::endl << "Incoming:" << std::endl; 2595 str << buffer << std::endl << "Incoming:" << std::endl;
2590 U64_to_str(mTotalBytesIn, tmp_str, sizeof(tmp_str)); 2596 tmp_str = U64_to_str(mTotalBytesIn);
2591 snprintf(buffer, MAX_STRING, "Total bytes received: %20s (%5.2f kbits per second)", tmp_str, ((F32)mTotalBytesIn * 0.008f) / run_time); /* Flawfinder: ignore */ 2597 buffer = llformat( "Total bytes received: %20s (%5.2f kbits per second)", tmp_str.c_str(), ((F32)mTotalBytesIn * 0.008f) / run_time);
2592 str << buffer << std::endl; 2598 str << buffer << std::endl;
2593 U64_to_str(mPacketsIn, tmp_str, sizeof(tmp_str)); 2599 tmp_str = U64_to_str(mPacketsIn);
2594 snprintf(buffer, MAX_STRING, "Total packets received: %20s (%5.2f packets per second)", tmp_str, ((F32) mPacketsIn / run_time)); /* Flawfinder: ignore */ 2600 buffer = llformat( "Total packets received: %20s (%5.2f packets per second)", tmp_str.c_str(), ((F32) mPacketsIn / run_time));
2595 str << buffer << std::endl; 2601 str << buffer << std::endl;
2596 snprintf(buffer, MAX_STRING, "Average packet size: %20.0f bytes", (F32)mTotalBytesIn / (F32)mPacketsIn); /* Flawfinder: ignore */ 2602 buffer = llformat( "Average packet size: %20.0f bytes", (F32)mTotalBytesIn / (F32)mPacketsIn);
2597 str << buffer << std::endl; 2603 str << buffer << std::endl;
2598 U64_to_str(mReliablePacketsIn, tmp_str, sizeof(tmp_str)); 2604 tmp_str = U64_to_str(mReliablePacketsIn);
2599 snprintf(buffer, MAX_STRING, "Total reliable packets: %20s (%5.2f%%)", tmp_str, 100.f * ((F32) mReliablePacketsIn)/((F32) mPacketsIn + 1)); /* Flawfinder: ignore */ 2605 buffer = llformat( "Total reliable packets: %20s (%5.2f%%)", tmp_str.c_str(), 100.f * ((F32) mReliablePacketsIn)/((F32) mPacketsIn + 1));
2600 str << buffer << std::endl; 2606 str << buffer << std::endl;
2601 U64_to_str(mCompressedPacketsIn, tmp_str, sizeof(tmp_str)); 2607 tmp_str = U64_to_str(mCompressedPacketsIn);
2602 snprintf(buffer, MAX_STRING, "Total compressed packets: %20s (%5.2f%%)", tmp_str, 100.f * ((F32) mCompressedPacketsIn)/((F32) mPacketsIn + 1)); /* Flawfinder: ignore */ 2608 buffer = llformat( "Total compressed packets: %20s (%5.2f%%)", tmp_str.c_str(), 100.f * ((F32) mCompressedPacketsIn)/((F32) mPacketsIn + 1));
2603 str << buffer << std::endl; 2609 str << buffer << std::endl;
2604 S64 savings = mUncompressedBytesIn - mCompressedBytesIn; 2610 S64 savings = mUncompressedBytesIn - mCompressedBytesIn;
2605 U64_to_str(savings, tmp_str, sizeof(tmp_str)); 2611 tmp_str = U64_to_str(savings);
2606 snprintf(buffer, MAX_STRING, "Total compression savings: %20s bytes", tmp_str); /* Flawfinder: ignore */ 2612 buffer = llformat( "Total compression savings: %20s bytes", tmp_str.c_str());
2607 str << buffer << std::endl; 2613 str << buffer << std::endl;
2608 U64_to_str(savings/(mCompressedPacketsIn +1), tmp_str, sizeof(tmp_str)); 2614 tmp_str = U64_to_str(savings/(mCompressedPacketsIn +1));
2609 snprintf(buffer, MAX_STRING, "Avg comp packet savings: %20s (%5.2f : 1)", tmp_str, ((F32) mUncompressedBytesIn)/((F32) mCompressedBytesIn+1)); /* Flawfinder: ignore */ 2615 buffer = llformat( "Avg comp packet savings: %20s (%5.2f : 1)", tmp_str.c_str(), ((F32) mUncompressedBytesIn)/((F32) mCompressedBytesIn+1));
2610 str << buffer << std::endl; 2616 str << buffer << std::endl;
2611 U64_to_str(savings/(mPacketsIn+1), tmp_str, sizeof(tmp_str)); 2617 tmp_str = U64_to_str(savings/(mPacketsIn+1));
2612 snprintf(buffer, MAX_STRING, "Avg overall comp savings: %20s (%5.2f : 1)", tmp_str, ((F32) mTotalBytesIn + (F32) savings)/((F32) mTotalBytesIn + 1.f)); /* Flawfinder: ignore */ 2618 buffer = llformat( "Avg overall comp savings: %20s (%5.2f : 1)", tmp_str.c_str(), ((F32) mTotalBytesIn + (F32) savings)/((F32) mTotalBytesIn + 1.f));
2613 2619
2614 // Outgoing 2620 // Outgoing
2615 str << buffer << std::endl << std::endl << "Outgoing:" << std::endl; 2621 str << buffer << std::endl << std::endl << "Outgoing:" << std::endl;
2616 U64_to_str(mTotalBytesOut, tmp_str, sizeof(tmp_str)); 2622 tmp_str = U64_to_str(mTotalBytesOut);
2617 snprintf(buffer, MAX_STRING, "Total bytes sent: %20s (%5.2f kbits per second)", tmp_str, ((F32)mTotalBytesOut * 0.008f) / run_time ); /* Flawfinder: ignore */ 2623 buffer = llformat( "Total bytes sent: %20s (%5.2f kbits per second)", tmp_str.c_str(), ((F32)mTotalBytesOut * 0.008f) / run_time );
2618 str << buffer << std::endl; 2624 str << buffer << std::endl;
2619 U64_to_str(mPacketsOut, tmp_str, sizeof(tmp_str)); 2625 tmp_str = U64_to_str(mPacketsOut);
2620 snprintf(buffer, MAX_STRING, "Total packets sent: %20s (%5.2f packets per second)", tmp_str, ((F32)mPacketsOut / run_time)); /* Flawfinder: ignore */ 2626 buffer = llformat( "Total packets sent: %20s (%5.2f packets per second)", tmp_str.c_str(), ((F32)mPacketsOut / run_time));
2621 str << buffer << std::endl; 2627 str << buffer << std::endl;
2622 snprintf(buffer, MAX_STRING, "Average packet size: %20.0f bytes", (F32)mTotalBytesOut / (F32)mPacketsOut); /* Flawfinder: ignore */ 2628 buffer = llformat( "Average packet size: %20.0f bytes", (F32)mTotalBytesOut / (F32)mPacketsOut);
2623 str << buffer << std::endl; 2629 str << buffer << std::endl;
2624 U64_to_str(mReliablePacketsOut, tmp_str, sizeof(tmp_str)); 2630 tmp_str = U64_to_str(mReliablePacketsOut);
2625 snprintf(buffer, MAX_STRING, "Total reliable packets: %20s (%5.2f%%)", tmp_str, 100.f * ((F32) mReliablePacketsOut)/((F32) mPacketsOut + 1)); /* Flawfinder: ignore */ 2631 buffer = llformat( "Total reliable packets: %20s (%5.2f%%)", tmp_str.c_str(), 100.f * ((F32) mReliablePacketsOut)/((F32) mPacketsOut + 1));
2626 str << buffer << std::endl; 2632 str << buffer << std::endl;
2627 U64_to_str(mCompressedPacketsOut, tmp_str, sizeof(tmp_str)); 2633 tmp_str = U64_to_str(mCompressedPacketsOut);
2628 snprintf(buffer, MAX_STRING, "Total compressed packets: %20s (%5.2f%%)", tmp_str, 100.f * ((F32) mCompressedPacketsOut)/((F32) mPacketsOut + 1)); /* Flawfinder: ignore */ 2634 buffer = llformat( "Total compressed packets: %20s (%5.2f%%)", tmp_str.c_str(), 100.f * ((F32) mCompressedPacketsOut)/((F32) mPacketsOut + 1));
2629 str << buffer << std::endl; 2635 str << buffer << std::endl;
2630 savings = mUncompressedBytesOut - mCompressedBytesOut; 2636 savings = mUncompressedBytesOut - mCompressedBytesOut;
2631 U64_to_str(savings, tmp_str, sizeof(tmp_str)); 2637 tmp_str = U64_to_str(savings);
2632 snprintf(buffer, MAX_STRING, "Total compression savings: %20s bytes", tmp_str); /* Flawfinder: ignore */ 2638 buffer = llformat( "Total compression savings: %20s bytes", tmp_str.c_str());
2633 str << buffer << std::endl; 2639 str << buffer << std::endl;
2634 U64_to_str(savings/(mCompressedPacketsOut +1), tmp_str, sizeof(tmp_str)); 2640 tmp_str = U64_to_str(savings/(mCompressedPacketsOut +1));
2635 snprintf(buffer, MAX_STRING, "Avg comp packet savings: %20s (%5.2f : 1)", tmp_str, ((F32) mUncompressedBytesOut)/((F32) mCompressedBytesOut+1)); /* Flawfinder: ignore */ 2641 buffer = llformat( "Avg comp packet savings: %20s (%5.2f : 1)", tmp_str.c_str(), ((F32) mUncompressedBytesOut)/((F32) mCompressedBytesOut+1));
2636 str << buffer << std::endl; 2642 str << buffer << std::endl;
2637 U64_to_str(savings/(mPacketsOut+1), tmp_str, sizeof(tmp_str)); 2643 tmp_str = U64_to_str(savings/(mPacketsOut+1));
2638 snprintf(buffer, MAX_STRING, "Avg overall comp savings: %20s (%5.2f : 1)", tmp_str, ((F32) mTotalBytesOut + (F32) savings)/((F32) mTotalBytesOut + 1.f)); /* Flawfinder: ignore */ 2644 buffer = llformat( "Avg overall comp savings: %20s (%5.2f : 1)", tmp_str.c_str(), ((F32) mTotalBytesOut + (F32) savings)/((F32) mTotalBytesOut + 1.f));
2639 str << buffer << std::endl << std::endl; 2645 str << buffer << std::endl << std::endl;
2640 snprintf(buffer, MAX_STRING, "SendPacket failures: %20d", mSendPacketFailureCount); /* Flawfinder: ignore */ 2646 buffer = llformat( "SendPacket failures: %20d", mSendPacketFailureCount);
2641 str << buffer << std::endl; 2647 str << buffer << std::endl;
2642 snprintf(buffer, MAX_STRING, "Dropped packets: %20d", mDroppedPackets); /* Flawfinder: ignore */ 2648 buffer = llformat( "Dropped packets: %20d", mDroppedPackets);
2643 str << buffer << std::endl; 2649 str << buffer << std::endl;
2644 snprintf(buffer, MAX_STRING, "Resent packets: %20d", mResentPackets); /* Flawfinder: ignore */ 2650 buffer = llformat( "Resent packets: %20d", mResentPackets);
2645 str << buffer << std::endl; 2651 str << buffer << std::endl;
2646 snprintf(buffer, MAX_STRING, "Failed reliable resends: %20d", mFailedResendPackets); /* Flawfinder: ignore */ 2652 buffer = llformat( "Failed reliable resends: %20d", mFailedResendPackets);
2647 str << buffer << std::endl; 2653 str << buffer << std::endl;
2648 snprintf(buffer, MAX_STRING, "Off-circuit rejected packets: %17d", mOffCircuitPackets); /* Flawfinder: ignore */ 2654 buffer = llformat( "Off-circuit rejected packets: %17d", mOffCircuitPackets);
2649 str << buffer << std::endl; 2655 str << buffer << std::endl;
2650 snprintf(buffer, MAX_STRING, "On-circuit invalid packets: %17d", mInvalidOnCircuitPackets); /* Flawfinder: ignore */ 2656 buffer = llformat( "On-circuit invalid packets: %17d", mInvalidOnCircuitPackets);
2651 str << buffer << std::endl << std::endl; 2657 str << buffer << std::endl << std::endl;
2652 2658
2653 str << "Decoding: " << std::endl; 2659 str << "Decoding: " << std::endl;
2654 snprintf(buffer, MAX_STRING, "%35s%10s%10s%10s%10s", "Message", "Count", "Time", "Max", "Avg"); /* Flawfinder: ignore */ 2660 buffer = llformat( "%35s%10s%10s%10s%10s", "Message", "Count", "Time", "Max", "Avg");
2655 str << buffer << std:: endl; 2661 str << buffer << std:: endl;
2656 F32 avg; 2662 F32 avg;
2657 for (message_template_name_map_t::const_iterator iter = mMessageTemplates.begin(), 2663 for (message_template_name_map_t::const_iterator iter = mMessageTemplates.begin(),
@@ -2662,7 +2668,7 @@ void LLMessageSystem::summarizeLogs(std::ostream& str)
2662 if(mt->mTotalDecoded > 0) 2668 if(mt->mTotalDecoded > 0)
2663 { 2669 {
2664 avg = mt->mTotalDecodeTime / (F32)mt->mTotalDecoded; 2670 avg = mt->mTotalDecodeTime / (F32)mt->mTotalDecoded;
2665 snprintf(buffer, MAX_STRING, "%35s%10u%10f%10f%10f", mt->mName, mt->mTotalDecoded, mt->mTotalDecodeTime, mt->mMaxDecodeTimePerMsg, avg); /* Flawfinder: ignore */ 2671 buffer = llformat( "%35s%10u%10f%10f%10f", mt->mName, mt->mTotalDecoded, mt->mTotalDecodeTime, mt->mMaxDecodeTimePerMsg, avg);
2666 str << buffer << std::endl; 2672 str << buffer << std::endl;
2667 } 2673 }
2668 } 2674 }
@@ -3928,6 +3934,20 @@ void LLMessageSystem::getString(const char *block, const char *var,
3928 blocknum); 3934 blocknum);
3929} 3935}
3930 3936
3937void LLMessageSystem::getStringFast(const char *block, const char *var,
3938 std::string& outstr, S32 blocknum)
3939{
3940 mMessageReader->getString(block, var, outstr, blocknum);
3941}
3942
3943void LLMessageSystem::getString(const char *block, const char *var,
3944 std::string& outstr, S32 blocknum )
3945{
3946 getStringFast(LLMessageStringTable::getInstance()->getString(block),
3947 LLMessageStringTable::getInstance()->getString(var), outstr,
3948 blocknum);
3949}
3950
3931S32 LLMessageSystem::getNumberOfBlocksFast(const char *blockname) 3951S32 LLMessageSystem::getNumberOfBlocksFast(const char *blockname)
3932{ 3952{
3933 return mMessageReader->getNumberOfBlocks(blockname); 3953 return mMessageReader->getNumberOfBlocks(blockname);