summaryrefslogtreecommitdiff
path: root/indra/newview/llappviewer.cpp
diff options
context:
space:
mode:
authorEric Tulla <tulla@lindenlab.com>2008-05-14 21:37:13 +0000
committerEric Tulla <tulla@lindenlab.com>2008-05-14 21:37:13 +0000
commite77de5d685ae441f72920f0e04d9887ee958745a (patch)
treeb3736831042b20be198dc9994ba68db1e8be2a14 /indra/newview/llappviewer.cpp
parent41e1ed5b4153019b07d97f54751db53fa248d8d4 (diff)
Result of svn merge -r 87455:87538 $SVN/branches/tulla/vc3-merge .
Passed QA as part of QAR-491.
Diffstat (limited to 'indra/newview/llappviewer.cpp')
-rw-r--r--indra/newview/llappviewer.cpp131
1 files changed, 84 insertions, 47 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index b8adfe5477..b1b59a71f8 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -122,6 +122,7 @@
#include "llhudeffecttrail.h"
#include "llvectorperfoptions.h"
#include "llurlsimstring.h"
+#include "llwatchdog.h"
// Included so that constants/settings might be initialized
// in save_settings_to_globals()
@@ -593,10 +594,16 @@ LLAppViewer::LLAppViewer() :
}
sInstance = this;
+
+ // Initialize the mainloop timeout.
+ mMainloopTimeout = new LLWatchdogTimeout();
}
LLAppViewer::~LLAppViewer()
{
+ // Initialize the mainloop timeout.
+ delete mMainloopTimeout;
+
// If we got to this destructor somehow, the app didn't hang.
removeMarkerFile();
}
@@ -650,7 +657,7 @@ bool LLAppViewer::init()
//
// Various introspection concerning the libs we're using.
//
- llinfos << "J2C Engine is: " << LLImageJ2C::getEngineInfo() << llendl;
+ LL_DEBUGS("InitInfo") << "J2C Engine is: " << LLImageJ2C::getEngineInfo() << LL_ENDL;
// Get the single value from the crash settings file, if it exists
std::string crash_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE);
@@ -693,15 +700,15 @@ bool LLAppViewer::init()
// Load art UUID information, don't require these strings to be declared in code.
LLString colors_base_filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "colors_base.xml");
- llinfos << "Loading base colors from " << colors_base_filename << llendl;
+ LL_DEBUGS("InitInfo") << "Loading base colors from " << colors_base_filename << LL_ENDL;
gColors.loadFromFileLegacy(colors_base_filename.c_str(), FALSE, TYPE_COL4U);
// Load overrides from user colors file
LLString user_colors_filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "colors.xml");
- llinfos << "Loading user colors from " << user_colors_filename << llendl;
+ LL_DEBUGS("InitInfo") << "Loading user colors from " << user_colors_filename << LL_ENDL;
if (gColors.loadFromFileLegacy(user_colors_filename.c_str(), FALSE, TYPE_COL4U) == 0)
{
- llinfos << "Cannot load user colors from " << user_colors_filename << llendl;
+ LL_DEBUGS("InitInfo") << "Cannot load user colors from " << user_colors_filename << LL_ENDL;
}
// Widget construction depends on LLUI being initialized
@@ -792,7 +799,7 @@ bool LLAppViewer::init()
#endif
gGLManager.getGLInfo(gDebugInfo);
- llinfos << gGLManager.getGLInfoString() << llendl;
+ gGLManager.printGLInfoString();
//load key settings
bind_keyboard_functions();
@@ -800,7 +807,7 @@ bool LLAppViewer::init()
// Load Default bindings
if (!gViewerKeyboard.loadBindings(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"keys.ini").c_str()))
{
- llerrs << "Unable to open keys.ini" << llendl;
+ LL_ERRS("InitInfo") << "Unable to open keys.ini" << LL_ENDL;
}
// Load Custom bindings (override defaults)
gViewerKeyboard.loadBindings(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"custom_keys.ini").c_str());
@@ -881,6 +888,10 @@ bool LLAppViewer::init()
bool LLAppViewer::mainLoop()
{
+ mMainloopTimeout = new LLWatchdogTimeout();
+ // *FIX:Mani - Make this a setting, once new settings exist in this branch.
+ mMainloopTimeout->setTimeout(5);
+
//-------------------------------------------
// Run main loop until time to quit
//-------------------------------------------
@@ -912,7 +923,7 @@ bool LLAppViewer::mainLoop()
{
LLFastTimer t2(LLFastTimer::FTM_MESSAGES);
#if LL_WINDOWS
- if (!LLWinDebug::setupExceptionHandler())
+ if (!LLWinDebug::checkExceptionHandler())
{
llwarns << " Someone took over my exception handler (post messagehandling)!" << llendl;
}
@@ -1061,6 +1072,8 @@ bool LLAppViewer::mainLoop()
}
//LLVFSThread::sLocal->pause(); // Prevent the VFS thread from running while rendering.
//LLLFSThread::sLocal->pause(); // Prevent the LFS thread from running while rendering.
+
+ mMainloopTimeout->ping();
}
}
@@ -1085,6 +1098,8 @@ bool LLAppViewer::mainLoop()
delete gServicePump;
+ mMainloopTimeout->stop();
+
llinfos << "Exiting main_loop" << llendflush;
return true;
@@ -1348,7 +1363,9 @@ bool LLAppViewer::cleanup()
gStaticVFS = NULL;
delete gVFS;
gVFS = NULL;
-
+
+ LLWatchdog::getInstance()->cleanup();
+
end_messaging_system();
// *NOTE:Mani - The following call is not thread safe.
@@ -1382,6 +1399,9 @@ bool LLAppViewer::initThreads()
#else
static const bool enable_threads = true;
#endif
+
+ LLWatchdog::getInstance()->init();
+
LLVFSThread::initClass(enable_threads && true);
LLLFSThread::initClass(enable_threads && true);
@@ -1436,7 +1456,7 @@ bool LLAppViewer::initLogging()
}
void LLAppViewer::loadSettingsFromDirectory(ELLPath path_index)
-{
+{
for(LLSD::map_iterator itr = mSettingsFileList.beginMap(); itr != mSettingsFileList.endMap(); ++itr)
{
LLString settings_name = (*itr).first;
@@ -1489,7 +1509,7 @@ std::string LLAppViewer::getSettingsFileName(const std::string& file)
}
bool LLAppViewer::initConfiguration()
-{
+{
//Set up internal pointers
gSettings[sGlobalSettingsName] = &gSavedSettings;
gSettings[sPerAccountSettingsName] = &gSavedPerAccountSettings;
@@ -2023,7 +2043,7 @@ bool LLAppViewer::initConfiguration()
bool LLAppViewer::initWindow()
{
- llinfos << "Initializing window..." << llendl;
+ LL_INFOS("AppInit") << "Initializing window..." << LL_ENDL;
// store setting in a global for easy access and modification
gNoRender = gSavedSettings.getBOOL("DisableRendering");
@@ -2193,22 +2213,22 @@ void LLAppViewer::writeSystemInfo()
gDebugInfo["OSInfo"] = getOSInfo().getOSStringSimple();
// Dump some debugging info
- llinfos << gSecondLife
+ LL_INFOS("SystemInfo") << gSecondLife
<< " version " << LL_VERSION_MAJOR << "." << LL_VERSION_MINOR << "." << LL_VERSION_PATCH
- << llendl;
+ << LL_ENDL;
// Dump the local time and time zone
time_t now;
time(&now);
char tbuffer[256]; /* Flawfinder: ignore */
strftime(tbuffer, 256, "%Y-%m-%dT%H:%M:%S %Z", localtime(&now));
- llinfos << "Local time: " << tbuffer << llendl;
+ LL_INFOS("SystemInfo") << "Local time: " << tbuffer << LL_ENDL;
// query some system information
- llinfos << "CPU info:\n" << gSysCPU << llendl;
- llinfos << "Memory info:\n" << gSysMemory << llendl;
- llinfos << "OS: " << getOSInfo().getOSStringSimple() << llendl;
- llinfos << "OS info: " << getOSInfo() << llendl;
+ LL_INFOS("SystemInfo") << "CPU info:\n" << gSysCPU << LL_ENDL;
+ LL_INFOS("SystemInfo") << "Memory info:\n" << gSysMemory << LL_ENDL;
+ LL_INFOS("SystemInfo") << "OS: " << getOSInfo().getOSStringSimple() << LL_ENDL;
+ LL_INFOS("SystemInfo") << "OS info: " << getOSInfo() << LL_ENDL;
}
void LLAppViewer::handleSyncViewerCrash()
@@ -2220,6 +2240,8 @@ void LLAppViewer::handleSyncViewerCrash()
void LLAppViewer::handleViewerCrash()
{
+ llinfos << "Handle viewer crash entry." << llendl;
+
LLAppViewer* pApp = LLAppViewer::instance();
if (pApp->beingDebugged())
{
@@ -2286,11 +2308,11 @@ void LLAppViewer::handleViewerCrash()
apr_file_t* crash_file = ll_apr_file_open(crash_file_name, LL_APR_W);
if (crash_file)
{
- llinfos << "Created crash marker file " << crash_file_name << llendl;
+ LL_INFOS("MarkerFile") << "Created crash marker file " << crash_file_name << LL_ENDL;
}
else
{
- llwarns << "Cannot create error marker file " << crash_file_name << llendl;
+ LL_WARNS("MarkerFile") << "Cannot create error marker file " << crash_file_name << LL_ENDL;
}
apr_file_close(crash_file);
}
@@ -2302,6 +2324,7 @@ void LLAppViewer::handleViewerCrash()
llofstream file(filename.c_str(), llofstream::binary);
if(file.good())
{
+ llinfos << "Handle viewer crash generating stats log." << llendl;
gMessageSystem->summarizeLogs(file);
file.close();
}
@@ -2317,6 +2340,7 @@ void LLAppViewer::handleViewerCrash()
// Close the debug file
pApp->closeDebug();
+
LLError::logToFile("");
// Remove the marker file, since otherwise we'll spawn a process that'll keep it locked
@@ -2347,7 +2371,7 @@ bool LLAppViewer::anotherInstanceRunning()
// If the file is currently locked, that means another process is already running.
std::string marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, MARKER_FILE_NAME);
- llinfos << "Checking marker file for lock..." << llendl;
+ LL_DEBUGS("MarkerFile") << "Checking marker file for lock..." << LL_ENDL;
//Freeze case checks
apr_file_t* fMarker = ll_apr_file_open(marker_file, LL_APR_RB);
@@ -2359,19 +2383,19 @@ bool LLAppViewer::anotherInstanceRunning()
if (fMarker == NULL)
{
// Another instance is running. Skip the rest of these operations.
- llinfos << "Marker file is locked." << llendl;
+ LL_INFOS("MarkerFile") << "Marker file is locked." << LL_ENDL;
return TRUE;
}
if (apr_file_lock(fMarker, APR_FLOCK_NONBLOCK | APR_FLOCK_EXCLUSIVE) != APR_SUCCESS) //flock(fileno(fMarker), LOCK_EX | LOCK_NB) == -1)
{
apr_file_close(fMarker);
- llinfos << "Marker file is locked." << llendl;
+ LL_INFOS("MarkerFile") << "Marker file is locked." << LL_ENDL;
return TRUE;
}
// No other instances; we'll lock this file now & delete on quit.
apr_file_close(fMarker);
}
- llinfos << "Marker file isn't locked." << llendl;
+ LL_DEBUGS("MarkerFile") << "Marker file isn't locked." << LL_ENDL;
return FALSE;
}
@@ -2382,7 +2406,7 @@ void LLAppViewer::initMarkerFile()
//There are marker files for two different types of crashes
mMarkerFileName = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,MARKER_FILE_NAME);
- llinfos << "Checking marker file for lock..." << llendl;
+ LL_DEBUGS("MarkerFile") << "Checking marker file for lock..." << LL_ENDL;
//We've got 4 things to test for here
// - Other Process Running (SecondLife.exec_marker present, locked)
@@ -2400,7 +2424,7 @@ void LLAppViewer::initMarkerFile()
if(fMarker != NULL)
{
apr_file_close(fMarker);
- llinfos << "Last exec LLError crashed, setting LastExecEvent to " << LAST_EXEC_LLERROR_CRASH << llendl;
+ LL_INFOS("MarkerFile") << "Last exec LLError crashed, setting LastExecEvent to " << LAST_EXEC_LLERROR_CRASH << LL_ENDL;
gLastExecEvent = LAST_EXEC_LOGOUT_FROZE;
}
fMarker = ll_apr_file_open(llerror_marker_file, LL_APR_RB);
@@ -2415,7 +2439,7 @@ void LLAppViewer::initMarkerFile()
if(fMarker != NULL)
{
apr_file_close(fMarker);
- llinfos << "Last exec crashed, setting LastExecEvent to " << LAST_EXEC_OTHER_CRASH << llendl;
+ LL_INFOS("MarkerFile") << "Last exec crashed, setting LastExecEvent to " << LAST_EXEC_OTHER_CRASH << LL_ENDL;
if(gLastExecEvent == LAST_EXEC_LOGOUT_FROZE) gLastExecEvent = LAST_EXEC_LOGOUT_CRASH;
else gLastExecEvent = LAST_EXEC_OTHER_CRASH;
}
@@ -2435,34 +2459,33 @@ void LLAppViewer::initMarkerFile()
{
apr_file_close(fMarker);
gLastExecEvent = LAST_EXEC_FROZE;
- llinfos << "Exec marker found: program froze on previous execution" << llendl;
+ LL_INFOS("MarkerFile") << "Exec marker found: program froze on previous execution" << LL_ENDL;
}
// Create the marker file for this execution & lock it
mMarkerFile = ll_apr_file_open(mMarkerFileName, LL_APR_W);
if (mMarkerFile)
{
- llinfos << "Marker file created." << llendl;
+ LL_DEBUGS("MarkerFile") << "Marker file created." << LL_ENDL;
}
else
{
- llinfos << "Failed to create marker file." << llendl;
+ LL_INFOS("MarkerFile") << "Failed to create marker file." << LL_ENDL;
return;
}
if (apr_file_lock(mMarkerFile, APR_FLOCK_NONBLOCK | APR_FLOCK_EXCLUSIVE) != APR_SUCCESS)
{
apr_file_close(mMarkerFile);
- llinfos << "Marker file cannot be locked." << llendl;
+ LL_INFOS("MarkerFile") << "Marker file cannot be locked." << LL_ENDL;
return;
}
- llinfos << "Marker file locked." << llendl;
- llinfos << "Exiting initMarkerFile()." << llendl;
+ LL_DEBUGS("MarkerFile") << "Marker file locked." << LL_ENDL;
}
void LLAppViewer::removeMarkerFile(bool leave_logout_marker)
{
- llinfos << "removeMarkerFile()" << llendl;
+ LL_DEBUGS("MarkerFile") << "removeMarkerFile()" << LL_ENDL;
if (mMarkerFile != NULL)
{
ll_apr_file_remove( mMarkerFileName );
@@ -2587,7 +2610,7 @@ bool LLAppViewer::initCache()
if (!gDirUtilp->setCacheDir(gSavedSettings.getString("CacheLocation")))
{
- llwarns << "Unable to set cache location" << llendl;
+ LL_WARNS("AppCache") << "Unable to set cache location" << LL_ENDL;
gSavedSettings.setString("CacheLocation", "");
}
@@ -2624,7 +2647,7 @@ bool LLAppViewer::initCache()
{
gSavedSettings.setU32("VFSOldSize", vfs_size_u32/MB);
}
- llinfos << "VFS CACHE SIZE: " << vfs_size/(1024*1024) << " MB" << llendl;
+ LL_INFOS("AppCache") << "VFS CACHE SIZE: " << vfs_size/(1024*1024) << " MB" << LL_ENDL;
// This has to happen BEFORE starting the vfs
//time_t ltime;
@@ -2688,8 +2711,7 @@ bool LLAppViewer::initCache()
{
sscanf(found_file.c_str() + start_pos, "%d", &old_salt);
}
- llinfos << "Default vfs data file not present, found " << old_vfs_data_file << llendl;
- llinfos << "Old salt: " << old_salt << llendl;
+ LL_DEBUGS("AppCache") << "Default vfs data file not present, found: " << old_vfs_data_file << " Old salt: " << old_salt << llendl;
}
}
@@ -2701,8 +2723,8 @@ bool LLAppViewer::initCache()
if (stat_result)
{
// We've got a bad/missing index file, nukem!
- llwarns << "Bad or missing vfx index file " << old_vfs_index_file << llendl;
- llwarns << "Removing old vfs data file " << old_vfs_data_file << llendl;
+ LL_WARNS("AppCache") << "Bad or missing vfx index file " << old_vfs_index_file << LL_ENDL;
+ LL_WARNS("AppCache") << "Removing old vfs data file " << old_vfs_data_file << LL_ENDL;
LLFile::remove(old_vfs_data_file);
LLFile::remove(old_vfs_index_file);
@@ -2739,7 +2761,7 @@ bool LLAppViewer::initCache()
if (resize_vfs)
{
- llinfos << "Removing old vfs and re-sizing" << llendl;
+ LL_DEBUGS("AppCache") << "Removing old vfs and re-sizing" << LL_ENDL;
LLFile::remove(old_vfs_data_file);
LLFile::remove(old_vfs_index_file);
@@ -2747,8 +2769,8 @@ bool LLAppViewer::initCache()
else if (old_salt != new_salt)
{
// move the vfs files to a new name before opening
- llinfos << "Renaming " << old_vfs_data_file << " to " << new_vfs_data_file << llendl;
- llinfos << "Renaming " << old_vfs_index_file << " to " << new_vfs_index_file << llendl;
+ LL_DEBUGS("AppCache") << "Renaming " << old_vfs_data_file << " to " << new_vfs_data_file << LL_ENDL;
+ LL_DEBUGS("AppCache") << "Renaming " << old_vfs_index_file << " to " << new_vfs_index_file << LL_ENDL;
LLFile::rename(old_vfs_data_file, new_vfs_data_file);
LLFile::rename(old_vfs_index_file, new_vfs_index_file);
}
@@ -2762,7 +2784,7 @@ bool LLAppViewer::initCache()
{
// Try again with fresh files
// (The constructor deletes corrupt files when it finds them.)
- llwarns << "VFS corrupt, deleted. Making new VFS." << llendl;
+ LL_WARNS("AppCache") << "VFS corrupt, deleted. Making new VFS." << LL_ENDL;
delete gVFS;
gVFS = new LLVFS(new_vfs_index_file, new_vfs_data_file, false, vfs_size_u32, false);
}
@@ -2783,9 +2805,8 @@ bool LLAppViewer::initCache()
void LLAppViewer::purgeCache()
{
- llinfos << "Purging Texture Cache..." << llendl;
+ LL_INFOS("AppCache") << "Purging Cache and Texture Cache..." << llendl;
LLAppViewer::getTextureCache()->purgeCache(LL_PATH_CACHE);
- llinfos << "Purging Cache..." << llendl;
std::string mask = gDirUtilp->getDirDelimiter() + "*.*";
gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,"").c_str(),mask);
}
@@ -2915,7 +2936,7 @@ void LLAppViewer::badNetworkHandler()
#if LL_WINDOWS
// Generates the minidump.
- LLWinDebug::handleException(NULL);
+ LLWinDebug::generateCrashStacks(NULL);
#endif
LLAppViewer::handleSyncViewerCrash();
LLAppViewer::handleViewerCrash();
@@ -3693,3 +3714,19 @@ void LLAppViewer::forceErrorSoftwareException()
// *FIX: Any way to insure it won't be handled?
throw;
}
+
+void LLAppViewer::startMainloopTimeout(F32 secs)
+{
+ if(secs < 0.0f)
+ {
+ secs = gSavedSettings.getF32("MainloopTimeoutDefault");
+ }
+
+ mMainloopTimeout->setTimeout(secs);
+ mMainloopTimeout->start();
+}
+
+void LLAppViewer::stopMainloopTimeout()
+{
+ mMainloopTimeout->stop();
+}