diff options
author | Christian Goetze <cg@lindenlab.com> | 2007-08-21 22:17:53 +0000 |
---|---|---|
committer | Christian Goetze <cg@lindenlab.com> | 2007-08-21 22:17:53 +0000 |
commit | ce0a5fe14590b8d675b885fccd5f79d7ea17a302 (patch) | |
tree | 3388e6f8ff02292ec4521d278c841801462945b8 /indra/llcommon | |
parent | b699ae454d8477d19342d320758cd993d1d28cec (diff) |
EFFECTIVE MERGE: svn merge -r 66133:68118 svn+ssh://svn/svn/linden/branches/maintenance into release
Actual action: branched maintenance-r68118, merged in release, then copied result into release
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/indra_constants.h | 1 | ||||
-rw-r--r-- | indra/llcommon/linden_common.h | 1 | ||||
-rw-r--r-- | indra/llcommon/llevent.cpp | 1 | ||||
-rw-r--r-- | indra/llcommon/llextendedstatus.h | 49 | ||||
-rw-r--r-- | indra/llcommon/lllivefile.cpp | 7 | ||||
-rw-r--r-- | indra/llcommon/llmetrics.cpp | 2 | ||||
-rw-r--r-- | indra/llcommon/llsys.cpp | 81 | ||||
-rw-r--r-- | indra/llcommon/llsys.h | 26 | ||||
-rw-r--r-- | indra/llcommon/llthread.h | 2 | ||||
-rw-r--r-- | indra/llcommon/lltimer.cpp | 16 | ||||
-rw-r--r-- | indra/llcommon/lltimer.h | 5 |
11 files changed, 160 insertions, 31 deletions
diff --git a/indra/llcommon/indra_constants.h b/indra/llcommon/indra_constants.h index 4ef4d21833..bf9218deac 100644 --- a/indra/llcommon/indra_constants.h +++ b/indra/llcommon/indra_constants.h @@ -116,6 +116,7 @@ const MASK MASK_ALT = 0x0002; const MASK MASK_SHIFT = 0x0004; const MASK MASK_NORMALKEYS = 0x0007; // A real mask - only get the bits for normal modifier keys const MASK MASK_MAC_CONTROL = 0x0008; // Un-mapped Ctrl key on Macs, not used on Windows +const MASK MASK_MODIFIERS = MASK_CONTROL|MASK_ALT|MASK_SHIFT|MASK_MAC_CONTROL; // Special keys go into >128 const KEY KEY_SPECIAL = 0x80; // special keys start here diff --git a/indra/llcommon/linden_common.h b/indra/llcommon/linden_common.h index 2ecda65d6f..5826bc917d 100644 --- a/indra/llcommon/linden_common.h +++ b/indra/llcommon/linden_common.h @@ -30,6 +30,7 @@ #include "stdtypes.h" #include "lldefs.h" #include "llerror.h" +#include "llextendedstatus.h" #include "llformat.h" #include "llstring.h" #include "lltimer.h" diff --git a/indra/llcommon/llevent.cpp b/indra/llcommon/llevent.cpp index 368159ee54..af776b1273 100644 --- a/indra/llcommon/llevent.cpp +++ b/indra/llcommon/llevent.cpp @@ -218,6 +218,7 @@ LLEventDispatcher::~LLEventDispatcher() if (impl) { delete impl; + impl = NULL; } } diff --git a/indra/llcommon/llextendedstatus.h b/indra/llcommon/llextendedstatus.h new file mode 100644 index 0000000000..a45a894be2 --- /dev/null +++ b/indra/llcommon/llextendedstatus.h @@ -0,0 +1,49 @@ +/** + * @file llextendedstatus.h + * @date August 2007 + * @brief extended status codes for curl/vfs/resident asset storage and delivery + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +#ifndef LL_LLEXTENDEDSTATUS_H +#define LL_LLEXTENDEDSTATUS_H + + +typedef S32 LLExtStat; + + +// Status provider groups - Top bits indicate which status type it is +// Zero is common status code (next section) +const LLExtStat LL_EXSTAT_CURL_RESULT = 1L<<30; // serviced by curl - use 1L if we really implement the below +const LLExtStat LL_EXSTAT_RES_RESULT = 2L<<30; // serviced by resident copy +const LLExtStat LL_EXSTAT_VFS_RESULT = 3L<<30; // serviced by vfs + + +// Common Status Codes +// +const LLExtStat LL_EXSTAT_NONE = 0x00000; // No extra info here - sorry! +const LLExtStat LL_EXSTAT_NULL_UUID = 0x10001; // null asset ID +const LLExtStat LL_EXSTAT_NO_UPSTREAM = 0x10002; // attempt to upload without a valid upstream method/provider +const LLExtStat LL_EXSTAT_REQUEST_DROPPED = 0x10003; // request was dropped unserviced +const LLExtStat LL_EXSTAT_NONEXISTENT_FILE = 0x10004; // trying to upload a file that doesn't exist +const LLExtStat LL_EXSTAT_BLOCKED_FILE = 0x10005; // trying to upload a file that we can't open + + +// curl status codes: +// +// Mask off LL_EXSTAT_CURL_RESULT for original result and +// see: libraries/include/curl/curl.h + + +// Memory-Resident status codes: +// None at present + + +// VFS status codes: +const LLExtStat LL_EXSTAT_VFS_CACHED = LL_EXSTAT_VFS_RESULT | 0x0001; +const LLExtStat LL_EXSTAT_VFS_CORRUPT = LL_EXSTAT_VFS_RESULT | 0x0002; + + +#endif // LL_LLEXTENDEDSTATUS_H diff --git a/indra/llcommon/lllivefile.cpp b/indra/llcommon/lllivefile.cpp index df2e940352..4bfc43e68a 100644 --- a/indra/llcommon/lllivefile.cpp +++ b/indra/llcommon/lllivefile.cpp @@ -126,8 +126,11 @@ namespace : LLEventTimer(refresh), mLiveFile(f) { } - void tick() - { mLiveFile.checkAndReload(); } + BOOL tick() + { + mLiveFile.checkAndReload(); + return FALSE; + } private: LLLiveFile& mLiveFile; diff --git a/indra/llcommon/llmetrics.cpp b/indra/llcommon/llmetrics.cpp index fee20b43ef..b193afebcc 100644 --- a/indra/llcommon/llmetrics.cpp +++ b/indra/llcommon/llmetrics.cpp @@ -47,7 +47,7 @@ void LLMetricsImpl::recordEventDetails(const std::string& location, metrics["location"] = location; metrics["stats"] = stats; - llinfos << "LLMETRICS: " << LLSDOStreamer<LLSDNotationFormatter>(metrics) << llendl; + llinfos << "LLMETRICS: " << LLSDNotationStreamer(metrics) << llendl; } // Store this: diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index b6d927d0f3..b1b92ae277 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -26,6 +26,7 @@ #elif LL_DARWIN # include <sys/sysctl.h> # include <sys/utsname.h> +# include <stdint.h> #elif LL_LINUX # include <sys/utsname.h> # include <unistd.h> @@ -462,57 +463,97 @@ LLMemoryInfo::LLMemoryInfo() { } -U32 LLMemoryInfo::getPhysicalMemory() const +#if LL_WINDOWS +static U32 LLMemoryAdjustKBResult(U32 inKB) +{ + // Moved this here from llfloaterabout.cpp + + //! \bug + // For some reason, the reported amount of memory is always wrong. + // The original adjustment assumes it's always off by one meg, however + // errors of as much as 2520 KB have been observed in the value + // returned from the GetMemoryStatusEx function. Here we keep the + // original adjustment from llfoaterabout.cpp until this can be + // fixed somehow. + inKB += 1024; + + return inKB; +} +#endif + +U32 LLMemoryInfo::getPhysicalMemoryKB() const { #if LL_WINDOWS - MEMORYSTATUS state; + MEMORYSTATUSEX state; state.dwLength = sizeof(state); - GlobalMemoryStatus(&state); + GlobalMemoryStatusEx(&state); - return (U32)state.dwTotalPhys; + return LLMemoryAdjustKBResult((U32)(state.ullTotalPhys >> 10)); #elif LL_DARWIN // This might work on Linux as well. Someone check... - unsigned int phys = 0; - int mib[2] = { CTL_HW, HW_PHYSMEM }; + uint64_t phys = 0; + int mib[2] = { CTL_HW, HW_MEMSIZE }; size_t len = sizeof(phys); sysctl(mib, 2, &phys, &len, NULL, 0); - return phys; + return (U32)(phys >> 10); + #elif LL_LINUX + U64 phys = 0; + phys = (U64)(getpagesize()) * (U64)(get_phys_pages()); + return (U32)(phys >> 10); - return getpagesize() * get_phys_pages(); #elif LL_SOLARIS - return getpagesize() * sysconf(_SC_PHYS_PAGES); + U64 phys = 0; + phys = (U64)(getpagesize()) * (U64)(sysconf(_SC_PHYS_PAGES)); + return (U32)(phys >> 10); + #else return 0; #endif } +U32 LLMemoryInfo::getPhysicalMemoryClamped() const +{ + // Return the total physical memory in bytes, but clamp it + // to no more than U32_MAX + + U32 phys_kb = getPhysicalMemoryKB(); + if (phys_kb >= 4194304 /* 4GB in KB */) + { + return U32_MAX; + } + else + { + return phys_kb << 10; + } +} + void LLMemoryInfo::stream(std::ostream& s) const { #if LL_WINDOWS - MEMORYSTATUS state; + MEMORYSTATUSEX state; state.dwLength = sizeof(state); - GlobalMemoryStatus(&state); + GlobalMemoryStatusEx(&state); s << "Percent Memory use: " << (U32)state.dwMemoryLoad << '%' << std::endl; - s << "Total Physical Kb: " << (U32)state.dwTotalPhys/1024 << std::endl; - s << "Avail Physical Kb: " << (U32)state.dwAvailPhys/1024 << std::endl; - s << "Total page Kb: " << (U32)state.dwTotalPageFile/1024 << std::endl; - s << "Avail page Kb: " << (U32)state.dwAvailPageFile/1024 << std::endl; - s << "Total Virtual Kb: " << (U32)state.dwTotalVirtual/1024 << std::endl; - s << "Avail Virtual Kb: " << (U32)state.dwAvailVirtual/1024 << std::endl; + s << "Total Physical KB: " << (U32)(state.ullTotalPhys/1024) << std::endl; + s << "Avail Physical KB: " << (U32)(state.ullAvailPhys/1024) << std::endl; + s << "Total page KB: " << (U32)(state.ullTotalPageFile/1024) << std::endl; + s << "Avail page KB: " << (U32)(state.ullAvailPageFile/1024) << std::endl; + s << "Total Virtual KB: " << (U32)(state.ullTotalVirtual/1024) << std::endl; + s << "Avail Virtual KB: " << (U32)(state.ullAvailVirtual/1024) << std::endl; #elif LL_DARWIN - U64 phys = 0; + uint64_t phys = 0; size_t len = sizeof(phys); if(sysctlbyname("hw.memsize", &phys, &len, NULL, 0) == 0) { - s << "Total Physical Kb: " << phys/1024 << std::endl; + s << "Total Physical KB: " << phys/1024 << std::endl; } else { @@ -523,7 +564,7 @@ void LLMemoryInfo::stream(std::ostream& s) const phys = (U64)(sysconf(_SC_PHYS_PAGES)) * (U64)(sysconf(_SC_PAGESIZE)/1024); - s << "Total Physical Kb: " << phys << std::endl; + s << "Total Physical KB: " << phys << std::endl; #else // *NOTE: This works on linux. What will it do on other systems? FILE* meminfo = LLFile::fopen(MEMINFO_FILE,"rb"); diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h index 4c80e2877c..866d33a2d8 100644 --- a/indra/llcommon/llsys.h +++ b/indra/llcommon/llsys.h @@ -69,13 +69,31 @@ private: std::string mCPUString; }; +//============================================================================= +// +// CLASS LLMemoryInfo + class LLMemoryInfo + +/*! @brief Class to query the memory subsystem + + @details + Here's how you use an LLMemoryInfo: + + LLMemoryInfo info; +<br> llinfos << info << llendl; +*/ { public: - LLMemoryInfo(); - void stream(std::ostream& s) const; - - U32 getPhysicalMemory() const; + LLMemoryInfo(); ///< Default constructor + void stream(std::ostream& s) const; ///< output text info to s + + U32 getPhysicalMemoryKB() const; ///< Memory size in KiloBytes + + /*! Memory size in bytes, if total memory is >= 4GB then U32_MAX will + ** be returned. + */ + U32 getPhysicalMemoryClamped() const; ///< Memory size in clamped bytes }; diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 659f73bee7..46ac5a8bd7 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -200,7 +200,7 @@ public: if (0 == res) { delete this; - res = 0; + return 0; } return res; } diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index f335458f24..73e73b9c44 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -505,13 +505,27 @@ LLEventTimer::~LLEventTimer() void LLEventTimer::updateClass() { + std::list<LLEventTimer*> completed_timers; for (std::list<LLEventTimer*>::iterator iter = sActiveList.begin(); iter != sActiveList.end(); ) { LLEventTimer* timer = *iter++; F32 et = timer->mEventTimer.getElapsedTimeF32(); if (et > timer->mPeriod) { timer->mEventTimer.reset(); - timer->tick(); + if ( timer->tick() ) + { + completed_timers.push_back( timer ); + } + } + } + + if ( completed_timers.size() > 0 ) + { + for (std::list<LLEventTimer*>::iterator completed_iter = completed_timers.begin(); + completed_iter != completed_timers.end(); + completed_iter++ ) + { + delete *completed_iter; } } } diff --git a/indra/llcommon/lltimer.h b/indra/llcommon/lltimer.h index 575bf9fc0b..6f67e19c48 100644 --- a/indra/llcommon/lltimer.h +++ b/indra/llcommon/lltimer.h @@ -122,11 +122,12 @@ void secondsToTimecodeString(F32 current_time, char *tcstring); class LLEventTimer { public: - LLEventTimer(F32 period); // period is the amount of time between each call to tick() + LLEventTimer(F32 period); // period is the amount of time between each call to tick() in seconds virtual ~LLEventTimer(); //function to be called at the supplied frequency - virtual void tick() = 0; + // Normally return FALSE; TRUE will delete the timer after the function returns. + virtual BOOL tick() = 0; static void updateClass(); |