From 0732b48be9c6378c31515ed92d29101e3743c8c9 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 13 Oct 2010 11:57:38 -0700 Subject: improved fastquit logic which should reliably disconnect viewer from sim --- indra/newview/llappviewer.cpp | 54 +++++++++++++++++++++------------------- indra/newview/llappviewer.h | 4 +-- indra/newview/llviewerwindow.cpp | 2 +- 3 files changed, 32 insertions(+), 28 deletions(-) (limited to 'indra') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 91fae709df..a245639fac 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1284,6 +1284,21 @@ bool LLAppViewer::mainLoop() return true; } +void LLAppViewer::flushVFSIO() +{ + while (1) + { + S32 pending = LLVFSThread::updateClass(0); + pending += LLLFSThread::updateClass(0); + if (!pending) + { + break; + } + llinfos << "Waiting for pending IO to finish: " << pending << llendflush; + ms_sleep(100); + } +} + bool LLAppViewer::cleanup() { // workaround for DEV-35406 crash on shutdown @@ -1419,17 +1434,7 @@ bool LLAppViewer::cleanup() llinfos << "Cache files removed" << llendflush; // Wait for any pending VFS IO - while (1) - { - S32 pending = LLVFSThread::updateClass(0); - pending += LLLFSThread::updateClass(0); - if (!pending) - { - break; - } - llinfos << "Waiting for pending IO to finish: " << pending << llendflush; - ms_sleep(100); - } + flushVFSIO(); llinfos << "Shutting down Views" << llendflush; // Destroy the UI @@ -2879,13 +2884,20 @@ void LLAppViewer::forceQuit() LLApp::setQuitting(); } -void LLAppViewer::fastQuit() +void LLAppViewer::fastQuit(S32 error_code) { - if (LLStartUp::getStartupState() >= STATE_STARTED) - { - sendLogoutRequest(); - } - _exit(isError()); + // finish pending transfers + flushVFSIO(); + // let sim know we're logging out + sendLogoutRequest(); + // flush network buffers by shutting down messaging system + end_messaging_system(); + // figure out the error code + S32 final_error_code = error_code ? error_code : (S32)isError(); + // this isn't a crash + removeMarkerFile(); + // get outta here + _exit(final_error_code); } void LLAppViewer::requestQuit() @@ -2973,14 +2985,6 @@ void LLAppViewer::earlyExitNoNotify() finish_early_exit( LLSD(), LLSD() ); } -void LLAppViewer::forceExit(S32 arg) -{ - removeMarkerFile(); - - // *FIX:Mani - This kind of exit hardly seems appropriate. - exit(arg); -} - void LLAppViewer::abortQuit() { llinfos << "abortQuit()" << llendl; diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index 0e7dbb738b..b2374a3426 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -65,14 +65,14 @@ public: virtual bool mainLoop(); // Override for the application main loop. Needs to at least gracefully notice the QUITTING state and exit. // Application control + void flushVFSIO(); // waits for vfs transfers to complete void forceQuit(); // Puts the viewer into 'shutting down without error' mode. - void fastQuit(); // Shuts down the viewer immediately after sending a logout message + void fastQuit(S32 error_code = 0); // Shuts down the viewer immediately after sending a logout message void requestQuit(); // Request a quit. A kinder, gentler quit. void userQuit(); // The users asks to quit. Confirm, then requestQuit() void earlyExit(const std::string& name, const LLSD& substitutions = LLSD()); // Display an error dialog and forcibly quit. void earlyExitNoNotify(); // Do not display error dialog then forcibly quit. - void forceExit(S32 arg); // exit() immediately (after some cleanup). void abortQuit(); // Called to abort a quit request. bool quitRequested() { return mQuitRequested; } diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 1c0bec3047..d2dab8f40c 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -1371,7 +1371,7 @@ LLViewerWindow::LLViewerWindow( LL_WARNS("Window") << "Unable to create window, be sure screen is set at 32-bit color in Control Panels->Display->Settings" << LL_ENDL; #endif - LLAppViewer::instance()->forceExit(1); + LLAppViewer::instance()->fastQuit(1); } // Get the real window rect the window was created with (since there are various OS-dependent reasons why -- cgit v1.2.3