summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2024-02-05 21:53:31 +0200
committerGitHub <noreply@github.com>2024-02-05 21:53:31 +0200
commitaa52c852d600aa6b2ea17cdd86f53972c95cca4a (patch)
tree757f3a3446e8f55e1cc073f1b3ab54d8e5af1b65 /indra/llcommon
parentedb2fb57f8782f966c7ea675d2e4c0135352ef02 (diff)
parent2a849259223a2d3fabafc118d711e73fa7fd604f (diff)
Merge pull request #734 from secondlife/DRTVWR-594-maint-Y
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llevents.cpp20
-rw-r--r--indra/llcommon/llevents.h5
-rw-r--r--indra/llcommon/llmemory.cpp30
3 files changed, 28 insertions, 27 deletions
diff --git a/indra/llcommon/llevents.cpp b/indra/llcommon/llevents.cpp
index 1a305ec3dc..70931f3a65 100644
--- a/indra/llcommon/llevents.cpp
+++ b/indra/llcommon/llevents.cpp
@@ -211,12 +211,21 @@ void LLEventPumps::clear()
}
}
-void LLEventPumps::reset()
+void LLEventPumps::reset(bool log_pumps)
{
// Reset every known LLEventPump instance. Leave it up to each instance to
// decide what to do with the reset() call.
+ if (log_pumps)
+ {
+ LL_INFOS() << "Resetting " << (S32)mPumpMap.size() << " pumps" << LL_ENDL;
+ }
+
for (PumpMap::value_type& pair : mPumpMap)
{
+ if (log_pumps)
+ {
+ LL_INFOS() << "Resetting pump " << pair.first << LL_ENDL;
+ }
pair.second->reset();
}
}
@@ -373,9 +382,11 @@ std::string LLEventPump::inventName(const std::string& pfx)
void LLEventPump::clear()
{
+ LLMutexLock lock(&mConnectionListMutex);
// Destroy the original LLStandardSignal instance, replacing it with a
// whole new one.
mSignal = std::make_shared<LLStandardSignal>();
+
mConnections.clear();
}
@@ -383,6 +394,7 @@ void LLEventPump::reset()
{
// Resetting mSignal is supposed to disconnect everything on its own
// But due to crash on 'reset' added explicit cleanup to get more data
+ LLMutexLock lock(&mConnectionListMutex);
ConnectionMap::const_iterator iter = mConnections.begin();
ConnectionMap::const_iterator end = mConnections.end();
while (iter!=end)
@@ -407,6 +419,8 @@ LLBoundListener LLEventPump::listen_impl(const std::string& name, const LLEventL
return LLBoundListener();
}
+ LLMutexLock lock(&mConnectionListMutex);
+
float nodePosition = 1.0;
// if the supplied name is empty we are not interested in the ordering mechanism
@@ -566,8 +580,9 @@ LLBoundListener LLEventPump::listen_impl(const std::string& name, const LLEventL
return bound;
}
-LLBoundListener LLEventPump::getListener(const std::string& name) const
+LLBoundListener LLEventPump::getListener(const std::string& name)
{
+ LLMutexLock lock(&mConnectionListMutex);
ConnectionMap::const_iterator found = mConnections.find(name);
if (found != mConnections.end())
{
@@ -579,6 +594,7 @@ LLBoundListener LLEventPump::getListener(const std::string& name) const
void LLEventPump::stopListening(const std::string& name)
{
+ LLMutexLock lock(&mConnectionListMutex);
ConnectionMap::iterator found = mConnections.find(name);
if (found != mConnections.end())
{
diff --git a/indra/llcommon/llevents.h b/indra/llcommon/llevents.h
index c1dbf4392f..bebcfacdcb 100644
--- a/indra/llcommon/llevents.h
+++ b/indra/llcommon/llevents.h
@@ -332,7 +332,7 @@ public:
* Reset all known LLEventPump instances
* workaround for DEV-35406 crash on shutdown
*/
- void reset();
+ void reset(bool log_pumps = false);
private:
friend class LLEventPump;
@@ -558,7 +558,7 @@ public:
/// Get the LLBoundListener associated with the passed name (dummy
/// LLBoundListener if not found)
- virtual LLBoundListener getListener(const std::string& name) const;
+ virtual LLBoundListener getListener(const std::string& name);
/**
* Instantiate one of these to block an existing connection:
* @code
@@ -601,6 +601,7 @@ private:
LLHandle<LLEventPumps> mRegistry;
std::string mName;
+ LLMutex mConnectionListMutex;
protected:
virtual LLBoundListener listen_impl(const std::string& name, const LLEventListener&,
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index 7cdf7254ff..574b9b8b3b 100644
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -38,6 +38,7 @@
#include <mach/mach_host.h>
#elif LL_LINUX
# include <unistd.h>
+# include <sys/resource.h>
#endif
#include "llmemory.h"
@@ -273,33 +274,16 @@ U64 LLMemory::getCurrentRSS()
U64 LLMemory::getCurrentRSS()
{
- static const char statPath[] = "/proc/self/stat";
- LLFILE *fp = LLFile::fopen(statPath, "r");
- U64 rss = 0;
+ struct rusage usage;
- if (fp == NULL)
- {
- LL_WARNS() << "couldn't open " << statPath << LL_ENDL;
+ if (getrusage(RUSAGE_SELF, &usage) != 0) {
+ // Error handling code could be here
return 0;
}
- // Eee-yew! See Documentation/filesystems/proc.txt in your
- // nearest friendly kernel tree for details.
-
- {
- int ret = fscanf(fp, "%*d (%*[^)]) %*c %*d %*d %*d %*d %*d %*d %*d "
- "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %Lu",
- &rss);
- if (ret != 1)
- {
- LL_WARNS() << "couldn't parse contents of " << statPath << LL_ENDL;
- rss = 0;
- }
- }
-
- fclose(fp);
-
- return rss;
+ // ru_maxrss (since Linux 2.6.32)
+ // This is the maximum resident set size used (in kilobytes).
+ return usage.ru_maxrss * 1024;
}
#else