2424 * $/LicenseInfo$
2525 */
2626
27+ // Precompiled header
28+ #include " linden_common.h"
2729
28- #include " llviewerprecompiledheaders.h"
2930#include " llwatchdog.h"
3031#include " llthread.h"
31- #include " llappviewer.h"
3232
3333constexpr U32 WATCHDOG_SLEEP_TIME_USEC = 1000000U ;
3434
@@ -67,7 +67,9 @@ class LLWatchdogTimerThread : public LLThread
6767};
6868
6969// LLWatchdogEntry
70- LLWatchdogEntry::LLWatchdogEntry ()
70+ LLWatchdogEntry::LLWatchdogEntry (const std::string& thread_name)
71+ : mThreadName(thread_name)
72+ , mThreadID(LLThread::currentID())
7173{
7274}
7375
@@ -89,11 +91,16 @@ void LLWatchdogEntry::stop()
8991 LLWatchdog::getInstance ()->remove (this );
9092 }
9193}
94+ std::string LLWatchdogEntry::getThreadName () const
95+ {
96+ return mThreadName + llformat (" : %d" , mThreadID );
97+ }
9298
9399// LLWatchdogTimeout
94100const std::string UNINIT_STRING = " uninitialized" ;
95101
96- LLWatchdogTimeout::LLWatchdogTimeout () :
102+ LLWatchdogTimeout::LLWatchdogTimeout (const std::string& thread_name) :
103+ LLWatchdogEntry(thread_name),
97104 mTimeout(0 .0f ),
98105 mPingState(UNINIT_STRING)
99106{
@@ -175,7 +182,7 @@ void LLWatchdog::remove(LLWatchdogEntry* e)
175182 unlockThread ();
176183}
177184
178- void LLWatchdog::init ()
185+ void LLWatchdog::init (func_t set_error_state_callback )
179186{
180187 if (!mSuspectsAccessMutex && !mTimer )
181188 {
@@ -188,6 +195,7 @@ void LLWatchdog::init()
188195 // start needs to use the mSuspectsAccessMutex
189196 mTimer ->start ();
190197 }
198+ mCreateMarkerFnc = set_error_state_callback;
191199}
192200
193201void LLWatchdog::cleanup ()
@@ -241,17 +249,23 @@ void LLWatchdog::run()
241249 {
242250 mTimer ->stop ();
243251 }
244- if (LLAppViewer::instance ()->logoutRequestSent ())
252+
253+ // Sets error marker file
254+ mCreateMarkerFnc ();
255+ // Todo1: Warn user?
256+ // Todo2: We probably want to report even if 5 seconds passed, just not error 'yet'.
257+ std::string last_state = (*result)->getLastState ();
258+ if (last_state.empty ())
245259 {
246- LLAppViewer::instance ()->createErrorMarker (LAST_EXEC_LOGOUT_FROZE);
260+ LL_ERRS () << " Watchdog timer for thread " << (*result)->getThreadName ()
261+ << " expired; assuming viewer is hung and crashing" << LL_ENDL;
247262 }
248263 else
249264 {
250- LLAppViewer::instance ()->createErrorMarker (LAST_EXEC_FROZE);
265+ LL_ERRS () << " Watchdog timer for thread " << (*result)->getThreadName ()
266+ << " expired with state: " << last_state
267+ << " ; assuming viewer is hung and crashing" << LL_ENDL;
251268 }
252- // Todo1: warn user?
253- // Todo2: We probably want to report even if 5 seconds passed, just not error 'yet'.
254- LL_ERRS () << " Watchdog timer expired; assuming viewer is hung and crashing" << LL_ENDL;
255269 }
256270 }
257271
0 commit comments