summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorDon Kjer <don@lindenlab.com>2013-03-13 19:17:13 +0000
committerDon Kjer <don@lindenlab.com>2013-03-13 19:17:13 +0000
commitcec50f8c142f4ff5f8358d9fa27884dd14f77eff (patch)
tree66ed6252d9326b73924a41e74304733be72343e1 /indra
parente42e9f897cae6fdb9db7c2742814c7df170e17a7 (diff)
Fix for gcc 4.6 build failures on Linux in llwindowsdl.cpp
Diffstat (limited to 'indra')
-rw-r--r--indra/llwindow/llwindowsdl.cpp38
1 files changed, 31 insertions, 7 deletions
diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp
index a15114cb9b..205466e936 100644
--- a/indra/llwindow/llwindowsdl.cpp
+++ b/indra/llwindow/llwindowsdl.cpp
@@ -1636,35 +1636,53 @@ void check_vm_bloat()
{
#if LL_LINUX
// watch our own VM and RSS sizes, warn if we bloated rapidly
- FILE *fp = fopen("/proc/self/stat", "r");
+ static const std::string STATS_FILE = "/proc/self/stat";
+ FILE *fp = fopen(STATS_FILE.c_str(), "r");
if (fp)
{
static long long last_vm_size = 0;
static long long last_rss_size = 0;
const long long significant_vm_difference = 250 * 1024*1024;
const long long significant_rss_difference = 50 * 1024*1024;
+ long long this_vm_size = 0;
+ long long this_rss_size = 0;
ssize_t res;
size_t dummy;
- char *ptr;
+ char *ptr = NULL;
for (int i=0; i<22; ++i) // parse past the values we don't want
{
- ptr = NULL;
res = getdelim(&ptr, &dummy, ' ', fp);
+ if (-1 == res)
+ {
+ llwarns << "Unable to parse " << STATS_FILE << llendl;
+ goto finally;
+ }
free(ptr);
+ ptr = NULL;
}
// 23rd space-delimited entry is vsize
- ptr = NULL;
res = getdelim(&ptr, &dummy, ' ', fp);
llassert(ptr);
- long long this_vm_size = atoll(ptr);
+ if (-1 == res)
+ {
+ llwarns << "Unable to parse " << STATS_FILE << llendl;
+ goto finally;
+ }
+ this_vm_size = atoll(ptr);
free(ptr);
- // 24th space-delimited entry is RSS
ptr = NULL;
+ // 24th space-delimited entry is RSS
res = getdelim(&ptr, &dummy, ' ', fp);
llassert(ptr);
- long long this_rss_size = getpagesize() * atoll(ptr);
+ if (-1 == res)
+ {
+ llwarns << "Unable to parse " << STATS_FILE << llendl;
+ goto finally;
+ }
+ this_rss_size = getpagesize() * atoll(ptr);
free(ptr);
+ ptr = NULL;
llinfos << "VM SIZE IS NOW " << (this_vm_size/(1024*1024)) << " MB, RSS SIZE IS NOW " << (this_rss_size/(1024*1024)) << " MB" << llendl;
@@ -1697,6 +1715,12 @@ void check_vm_bloat()
last_rss_size = this_rss_size;
last_vm_size = this_vm_size;
+finally:
+ if (NULL != ptr)
+ {
+ free(ptr);
+ ptr = NULL;
+ }
fclose(fp);
}
#endif // LL_LINUX