From b8da1259ba9fa9b2afc0a2b6050b147dbf13ccb8 Mon Sep 17 00:00:00 2001
From: Rider Linden <rider@lindenlab.com>
Date: Mon, 21 Oct 2024 16:35:23 -0700
Subject: Issue #2907: Process metadata sent along with chats of type
 IM_NOTHING_SPECIAL, The metadata can contain information about the bot status
 of the sender. It may also contain a system-injected notification that is
 displayed to the agent as part of the 1:1 chat window.

---
 indra/llmessage/message_prehash.cpp | 1 +
 indra/llmessage/message_prehash.h   | 1 +
 2 files changed, 2 insertions(+)

(limited to 'indra/llmessage')

diff --git a/indra/llmessage/message_prehash.cpp b/indra/llmessage/message_prehash.cpp
index d3b80d684f..7ab25908e2 100644
--- a/indra/llmessage/message_prehash.cpp
+++ b/indra/llmessage/message_prehash.cpp
@@ -1404,3 +1404,4 @@ char const* const _PREHASH_ExperienceID = LLMessageStringTable::getInstance()->g
 char const* const _PREHASH_LargeGenericMessage = LLMessageStringTable::getInstance()->getString("LargeGenericMessage");
 char const* const _PREHASH_GameControlInput = LLMessageStringTable::getInstance()->getString("GameControlInput");
 char const* const _PREHASH_AxisData = LLMessageStringTable::getInstance()->getString("AxisData");
+char const* const _PREHASH_MetaData = LLMessageStringTable::getInstance()->getString("MetaData");
diff --git a/indra/llmessage/message_prehash.h b/indra/llmessage/message_prehash.h
index 5449eaf2a5..88dee7f961 100644
--- a/indra/llmessage/message_prehash.h
+++ b/indra/llmessage/message_prehash.h
@@ -1405,5 +1405,6 @@ extern char const* const _PREHASH_ExperienceID;
 extern char const* const _PREHASH_LargeGenericMessage;
 extern char const* const _PREHASH_GameControlInput;
 extern char const* const _PREHASH_AxisData;
+extern char const* const _PREHASH_MetaData;
 
 #endif
-- 
cgit v1.2.3


From 8e737a5d45157426cb84927170a78baea2106813 Mon Sep 17 00:00:00 2001
From: Nat Goodspeed <nat@lindenlab.com>
Date: Tue, 22 Oct 2024 09:52:36 -0400
Subject: LLCoprocedurePool::coprocedureInvokerCoro() sets status to task name

LLCoprocedurePool coroutines are generic; its coroutine name alone doesn't
tell us much. We can only know what one is doing by its current task name.
Use LLCoros::setStatus() to associate the task name with the coroutine.
---
 indra/llmessage/llcoproceduremanager.cpp | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

(limited to 'indra/llmessage')

diff --git a/indra/llmessage/llcoproceduremanager.cpp b/indra/llmessage/llcoproceduremanager.cpp
index 13972ad399..5539ca7b86 100644
--- a/indra/llmessage/llcoproceduremanager.cpp
+++ b/indra/llmessage/llcoproceduremanager.cpp
@@ -403,6 +403,7 @@ void LLCoprocedurePool::coprocedureInvokerCoro(
     CoprocQueuePtr pendingCoprocs,
     LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter)
 {
+    std::string prevtask;
     for (;;)
     {
         // It is VERY IMPORTANT that we instantiate a new ptr_t just before
@@ -424,10 +425,25 @@ void LLCoprocedurePool::coprocedureInvokerCoro(
         // destroyed during pop_wait_for().
         QueuedCoproc::ptr_t coproc;
         boost::fibers::channel_op_status status;
+        // Each time control reaches our custom coroutine scheduler, we check
+        // how long the previous coroutine ran before yielding, and report
+        // coroutines longer than a certain cutoff. But these coprocedure pool
+        // coroutines are generic; the only way we know what work they're
+        // doing is the task 'status' set by LLCoros::setStatus(). But what if
+        // the coroutine runs the task to completion and returns to waiting?
+        // It does no good to report that "waiting" ran long. So each time we
+        // enter "waiting" status, also report the *previous* task name.
+        std::string waiting = "waiting", newstatus;
+        if (prevtask.empty())
         {
-            LLCoros::TempStatus st("waiting for work for 10s");
-            status = pendingCoprocs->pop_wait_for(coproc, std::chrono::seconds(10));
+            newstatus = waiting;
         }
+        else
+        {
+            newstatus = stringize("done ", prevtask, "; ", waiting);
+        }
+        LLCoros::setStatus(newstatus);
+        status = pendingCoprocs->pop_wait_for(coproc, std::chrono::seconds(10));
         if (status == boost::fibers::channel_op_status::closed)
         {
             break;
@@ -436,6 +452,7 @@ void LLCoprocedurePool::coprocedureInvokerCoro(
         if(status == boost::fibers::channel_op_status::timeout)
         {
             LL_DEBUGS_ONCE("CoProcMgr") << "pool '" << mPoolName << "' waiting." << LL_ENDL;
+            prevtask.clear();
             continue;
         }
         // we actually popped an item
@@ -446,6 +463,9 @@ void LLCoprocedurePool::coprocedureInvokerCoro(
 
         try
         {
+            // set "status" of pool coroutine to the name of the coproc task
+            prevtask = coproc->mName;
+            LLCoros::setStatus(prevtask);
             coproc->mProc(httpAdapter, coproc->mId);
         }
         catch (const LLCoros::Stop &e)
-- 
cgit v1.2.3