summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llappcorehttp.cpp4
-rw-r--r--indra/newview/llappdelegate-objc.mm24
-rw-r--r--indra/newview/llappviewer.cpp464
-rw-r--r--indra/newview/llappviewer.h3
-rw-r--r--indra/newview/llappviewerlinux.cpp6
-rw-r--r--indra/newview/llappviewermacosx.cpp9
-rw-r--r--indra/newview/llappviewerwin32.cpp6
-rw-r--r--indra/newview/llcommandlineparser.cpp25
-rw-r--r--indra/newview/llcompilequeue.cpp323
-rw-r--r--indra/newview/llsecapi.cpp5
-rw-r--r--indra/newview/llsecapi.h34
-rw-r--r--indra/newview/llsechandler_basic.cpp53
12 files changed, 451 insertions, 505 deletions
diff --git a/indra/newview/llappcorehttp.cpp b/indra/newview/llappcorehttp.cpp
index 49291ea564..dbcae57de7 100644
--- a/indra/newview/llappcorehttp.cpp
+++ b/indra/newview/llappcorehttp.cpp
@@ -534,7 +534,7 @@ LLCore::HttpStatus LLAppCoreHttp::sslVerify(const std::string &url,
// somewhat clumsy, as we may run into errors that do not map directly to curl
// error codes. Should be refactored with login refactoring, perhaps.
result = LLCore::HttpStatus(LLCore::HttpStatus::EXT_CURL_EASY, CURLE_SSL_CACERT);
- result.setMessage(cert_exception.getMessage());
+ result.setMessage(cert_exception.what());
LLPointer<LLCertificate> cert = cert_exception.getCert();
cert->ref(); // adding an extra ref here
result.setErrorData(cert.get());
@@ -544,7 +544,7 @@ LLCore::HttpStatus LLAppCoreHttp::sslVerify(const std::string &url,
catch (LLCertException &cert_exception)
{
result = LLCore::HttpStatus(LLCore::HttpStatus::EXT_CURL_EASY, CURLE_SSL_PEER_CERTIFICATE);
- result.setMessage(cert_exception.getMessage());
+ result.setMessage(cert_exception.what());
LLPointer<LLCertificate> cert = cert_exception.getCert();
cert->ref(); // adding an extra ref here
result.setErrorData(cert.get());
diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm
index 549df80fa1..be8877328d 100644
--- a/indra/newview/llappdelegate-objc.mm
+++ b/indra/newview/llappdelegate-objc.mm
@@ -48,16 +48,19 @@
- (void) applicationDidFinishLaunching:(NSNotification *)notification
{
frameTimer = nil;
-
+
[self languageUpdated];
-
+
if (initViewer())
{
- frameTimer = [NSTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(mainLoop) userInfo:nil repeats:YES];
+ // Set up recurring calls to oneFrame (repeating timer with timeout 0)
+ // until applicationShouldTerminate.
+ frameTimer = [NSTimer scheduledTimerWithTimeInterval:0.0 target:self
+ selector:@selector(oneFrame) userInfo:nil repeats:YES];
} else {
handleQuit();
}
-
+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(languageUpdated) name:@"NSTextInputContextKeyboardSelectionDidChangeNotification" object:nil];
// [[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
@@ -96,22 +99,29 @@
- (NSApplicationDelegateReply) applicationShouldTerminate:(NSApplication *)sender
{
- if (!runMainLoop())
+ // run one frame to assess state
+ if (!pumpMainLoop())
{
+ // pumpMainLoop() returns true when done, false if it wants to be
+ // called again. Since it returned false, do not yet cancel
+ // frameTimer.
handleQuit();
return NSTerminateCancel;
} else {
+ // pumpMainLoop() returned true: it's done. Okay, done with frameTimer.
[frameTimer release];
cleanupViewer();
return NSTerminateNow;
}
}
-- (void) mainLoop
+- (void) oneFrame
{
- bool appExiting = runMainLoop();
+ bool appExiting = pumpMainLoop();
if (appExiting)
{
+ // Once pumpMainLoop() reports that we're done, cancel frameTimer:
+ // stop the repetitive calls.
[frameTimer release];
[[NSApplication sharedApplication] terminate:self];
}
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 721a7cc00b..72e5eefc49 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -122,6 +122,7 @@
#include "llleap.h"
#include "stringize.h"
#include "llcoros.h"
+#include "llexception.h"
#if !LL_LINUX
#include "cef/llceflib.h"
#endif
@@ -131,6 +132,7 @@
#include <boost/foreach.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/regex.hpp>
+#include <boost/throw_exception.hpp>
#if LL_WINDOWS
# include <share.h> // For _SH_DENYWR in processMarkerFiles
@@ -232,7 +234,6 @@
#include "llcoproceduremanager.h"
#include "llviewereventrecorder.h"
-
// *FIX: These extern globals should be cleaned up.
// The globals either represent state/config/resource-storage of either
// this app, or another 'component' of the viewer. App globals should be
@@ -770,9 +771,6 @@ bool LLAppViewer::init()
//
// Start of the application
//
-#ifdef LL_DARWIN
- mMainLoopInitialized = false;
-#endif
// initialize LLWearableType translation bridge.
// Memory will be cleaned up in ::cleanupClass()
@@ -1221,6 +1219,23 @@ bool LLAppViewer::init()
boost::bind(&LLControlGroup::getU32, boost::ref(gSavedSettings), _1),
boost::bind(&LLControlGroup::declareU32, boost::ref(gSavedSettings), _1, _2, _3, LLControlVariable::PERSIST_ALWAYS));
+ /*----------------------------------------------------------------------*/
+ // nat 2016-06-29 moved the following here from the former mainLoop().
+ mMainloopTimeout = new LLWatchdogTimeout();
+
+ // Create IO Pump to use for HTTP Requests.
+ gServicePump = new LLPumpIO(gAPRPoolp);
+
+ // Note: this is where gLocalSpeakerMgr and gActiveSpeakerMgr used to be instantiated.
+
+ LLVoiceChannel::initClass();
+ LLVoiceClient::getInstance()->init(gServicePump);
+ LLVoiceChannel::setCurrentVoiceChannelChangedCallback(boost::bind(&LLFloaterIMContainer::onCurrentChannelChanged, _1), true);
+
+ joystick = LLViewerJoystick::getInstance();
+ joystick->setNeedsReset(true);
+ /*----------------------------------------------------------------------*/
+
return true;
}
@@ -1295,298 +1310,256 @@ static LLTrace::BlockTimerStatHandle FTM_AGENT_UPDATE("Update");
// externally visible timers
LLTrace::BlockTimerStatHandle FTM_FRAME("Frame");
-bool LLAppViewer::mainLoop()
+bool LLAppViewer::frame()
{
-#ifdef LL_DARWIN
- if (!mMainLoopInitialized)
-#endif
- {
- LL_INFOS() << "Entering main_loop" << LL_ENDL;
- mMainloopTimeout = new LLWatchdogTimeout();
-
- //-------------------------------------------
- // Run main loop until time to quit
- //-------------------------------------------
-
- // Create IO Pump to use for HTTP Requests.
- gServicePump = new LLPumpIO(gAPRPoolp);
-
- // Note: this is where gLocalSpeakerMgr and gActiveSpeakerMgr used to be instantiated.
-
- LLVoiceChannel::initClass();
- LLVoiceClient::getInstance()->init(gServicePump);
- LLVoiceChannel::setCurrentVoiceChannelChangedCallback(boost::bind(&LLFloaterIMContainer::onCurrentChannelChanged, _1), true);
-
- joystick = LLViewerJoystick::getInstance();
- joystick->setNeedsReset(true);
-
-#ifdef LL_DARWIN
- // Ensure that this section of code never gets called again on OS X.
- mMainLoopInitialized = true;
-#endif
- }
- // As we do not (yet) send data on the mainloop LLEventPump that varies
- // with each frame, no need to instantiate a new LLSD event object each
- // time. Obviously, if that changes, just instantiate the LLSD at the
- // point of posting.
-
LLEventPump& mainloop(LLEventPumps::instance().obtain("mainloop"));
-
- LLSD newFrame;
-
+ LLSD newFrame;
+
LLTimer frameTimer,idleTimer;
LLTimer debugTime;
-
+
//LLPrivateMemoryPoolTester::getInstance()->run(false) ;
//LLPrivateMemoryPoolTester::getInstance()->run(true) ;
//LLPrivateMemoryPoolTester::destroy() ;
- // Handle messages
-#ifdef LL_DARWIN
- if (!LLApp::isExiting())
-#else
- while (!LLApp::isExiting())
-#endif
- {
- LL_RECORD_BLOCK_TIME(FTM_FRAME);
- LLTrace::BlockTimer::processTimes();
- LLTrace::get_frame_recording().nextPeriod();
- LLTrace::BlockTimer::logStats();
+ LL_RECORD_BLOCK_TIME(FTM_FRAME);
+ LLTrace::BlockTimer::processTimes();
+ LLTrace::get_frame_recording().nextPeriod();
+ LLTrace::BlockTimer::logStats();
- LLTrace::get_thread_recorder()->pullFromChildren();
+ LLTrace::get_thread_recorder()->pullFromChildren();
- //clear call stack records
- LL_CLEAR_CALLSTACKS();
+ //clear call stack records
+ LL_CLEAR_CALLSTACKS();
- //check memory availability information
- checkMemory() ;
-
- try
+ //check memory availability information
+ checkMemory() ;
+
+ try
+ {
+ pingMainloopTimeout("Main:MiscNativeWindowEvents");
+
+ if (gViewerWindow)
{
- pingMainloopTimeout("Main:MiscNativeWindowEvents");
+ LL_RECORD_BLOCK_TIME(FTM_MESSAGES);
+ gViewerWindow->getWindow()->processMiscNativeEvents();
+ }
- if (gViewerWindow)
+ pingMainloopTimeout("Main:GatherInput");
+
+ if (gViewerWindow)
+ {
+ LL_RECORD_BLOCK_TIME(FTM_MESSAGES);
+ if (!restoreErrorTrap())
{
- LL_RECORD_BLOCK_TIME(FTM_MESSAGES);
- gViewerWindow->getWindow()->processMiscNativeEvents();
+ LL_WARNS() << " Someone took over my signal/exception handler (post messagehandling)!" << LL_ENDL;
}
-
- pingMainloopTimeout("Main:GatherInput");
-
- if (gViewerWindow)
- {
- LL_RECORD_BLOCK_TIME(FTM_MESSAGES);
- if (!restoreErrorTrap())
- {
- LL_WARNS() << " Someone took over my signal/exception handler (post messagehandling)!" << LL_ENDL;
- }
- gViewerWindow->getWindow()->gatherInput();
- }
+ gViewerWindow->getWindow()->gatherInput();
+ }
#if 1 && !LL_RELEASE_FOR_DOWNLOAD
- // once per second debug info
- if (debugTime.getElapsedTimeF32() > 1.f)
- {
- debugTime.reset();
- }
-
+ // once per second debug info
+ if (debugTime.getElapsedTimeF32() > 1.f)
+ {
+ debugTime.reset();
+ }
+
#endif
- //memory leaking simulation
- LLFloaterMemLeak* mem_leak_instance =
- LLFloaterReg::findTypedInstance<LLFloaterMemLeak>("mem_leaking");
- if(mem_leak_instance)
- {
- mem_leak_instance->idle() ;
- }
+ //memory leaking simulation
+ LLFloaterMemLeak* mem_leak_instance =
+ LLFloaterReg::findTypedInstance<LLFloaterMemLeak>("mem_leaking");
+ if(mem_leak_instance)
+ {
+ mem_leak_instance->idle() ;
+ }
- // canonical per-frame event
- mainloop.post(newFrame);
+ // canonical per-frame event
+ mainloop.post(newFrame);
- if (!LLApp::isExiting())
+ if (!LLApp::isExiting())
+ {
+ pingMainloopTimeout("Main:JoystickKeyboard");
+
+ // Scan keyboard for movement keys. Command keys and typing
+ // are handled by windows callbacks. Don't do this until we're
+ // done initializing. JC
+ if ((gHeadlessClient || gViewerWindow->getWindow()->getVisible())
+ && gViewerWindow->getActive()
+ && !gViewerWindow->getWindow()->getMinimized()
+ && LLStartUp::getStartupState() == STATE_STARTED
+ && (gHeadlessClient || !gViewerWindow->getShowProgress())
+ && !gFocusMgr.focusLocked())
{
- pingMainloopTimeout("Main:JoystickKeyboard");
+ joystick->scanJoystick();
+ gKeyboard->scanKeyboard();
+ }
+
+ // Update state based on messages, user input, object idle.
+ {
+ pauseMainloopTimeout(); // *TODO: Remove. Messages shouldn't be stalling for 20+ seconds!
- // Scan keyboard for movement keys. Command keys and typing
- // are handled by windows callbacks. Don't do this until we're
- // done initializing. JC
- if ((gHeadlessClient || gViewerWindow->getWindow()->getVisible())
- && gViewerWindow->getActive()
- && !gViewerWindow->getWindow()->getMinimized()
- && LLStartUp::getStartupState() == STATE_STARTED
- && (gHeadlessClient || !gViewerWindow->getShowProgress())
- && !gFocusMgr.focusLocked())
- {
- joystick->scanJoystick();
- gKeyboard->scanKeyboard();
- }
+ LL_RECORD_BLOCK_TIME(FTM_IDLE);
+ idle();
- // Update state based on messages, user input, object idle.
- {
- pauseMainloopTimeout(); // *TODO: Remove. Messages shouldn't be stalling for 20+ seconds!
-
- LL_RECORD_BLOCK_TIME(FTM_IDLE);
- idle();
+ resumeMainloopTimeout();
+ }
- resumeMainloopTimeout();
- }
-
- if (gDoDisconnect && (LLStartUp::getStartupState() == STATE_STARTED))
- {
- pauseMainloopTimeout();
- saveFinalSnapshot();
- disconnectViewer();
- resumeMainloopTimeout();
- }
+ if (gDoDisconnect && (LLStartUp::getStartupState() == STATE_STARTED))
+ {
+ pauseMainloopTimeout();
+ saveFinalSnapshot();
+ disconnectViewer();
+ resumeMainloopTimeout();
+ }
- // Render scene.
- // *TODO: Should we run display() even during gHeadlessClient? DK 2011-02-18
- if (!LLApp::isExiting() && !gHeadlessClient)
- {
- pingMainloopTimeout("Main:Display");
- gGLActive = TRUE;
- display();
- pingMainloopTimeout("Main:Snapshot");
- LLFloaterSnapshot::update(); // take snapshots
+ // Render scene.
+ // *TODO: Should we run display() even during gHeadlessClient? DK 2011-02-18
+ if (!LLApp::isExiting() && !gHeadlessClient)
+ {
+ pingMainloopTimeout("Main:Display");
+ gGLActive = TRUE;
+ display();
+ pingMainloopTimeout("Main:Snapshot");
+ LLFloaterSnapshot::update(); // take snapshots
LLFloaterOutfitSnapshot::update();
- gGLActive = FALSE;
- }
+ gGLActive = FALSE;
}
+ }
+
+ pingMainloopTimeout("Main:Sleep");
- pingMainloopTimeout("Main:Sleep");
+ pauseMainloopTimeout();
+
+ // Sleep and run background threads
+ {
+ LL_RECORD_BLOCK_TIME(FTM_SLEEP);
- pauseMainloopTimeout();
+ // yield some time to the os based on command line option
+ if(mYieldTime >= 0)
+ {
+ LL_RECORD_BLOCK_TIME(FTM_YIELD);
+ ms_sleep(mYieldTime);
+ }
- // Sleep and run background threads
+ // yield cooperatively when not running as foreground window
+ if ( (gViewerWindow && !gViewerWindow->getWindow()->getVisible())
+ || !gFocusMgr.getAppHasFocus())
{
- LL_RECORD_BLOCK_TIME(FTM_SLEEP);
-
- // yield some time to the os based on command line option
- if(mYieldTime >= 0)
+ // Sleep if we're not rendering, or the window is minimized.
+ S32 milliseconds_to_sleep = llclamp(gSavedSettings.getS32("BackgroundYieldTime"), 0, 1000);
+ // don't sleep when BackgroundYieldTime set to 0, since this will still yield to other threads
+ // of equal priority on Windows
+ if (milliseconds_to_sleep > 0)
{
- LL_RECORD_BLOCK_TIME(FTM_YIELD);
- ms_sleep(mYieldTime);
+ ms_sleep(milliseconds_to_sleep);
+ // also pause worker threads during this wait period
+ LLAppViewer::getTextureCache()->pause();
+ LLAppViewer::getImageDecodeThread()->pause();
}
+ }
+
+ if (mRandomizeFramerate)
+ {
+ ms_sleep(rand() % 200);
+ }
+
+ if (mPeriodicSlowFrame
+ && (gFrameCount % 10 == 0))
+ {
+ LL_INFOS() << "Periodic slow frame - sleeping 500 ms" << LL_ENDL;
+ ms_sleep(500);
+ }
+
+ const F64Milliseconds max_idle_time = llmin(.005f*10.f*(F32Milliseconds)gFrameTimeSeconds, F32Milliseconds(5)); // 5 ms a second
+ idleTimer.reset();
+ S32 total_work_pending = 0;
+ S32 total_io_pending = 0;
+ while(1)
+ {
+ S32 work_pending = 0;
+ S32 io_pending = 0;
+ F32 max_time = llmin(gFrameIntervalSeconds.value() *10.f, 1.f);
+
+ work_pending += updateTextureThreads(max_time);
- // yield cooperatively when not running as foreground window
- if ( (gViewerWindow && !gViewerWindow->getWindow()->getVisible())
- || !gFocusMgr.getAppHasFocus())
{
- // Sleep if we're not rendering, or the window is minimized.
- S32 milliseconds_to_sleep = llclamp(gSavedSettings.getS32("BackgroundYieldTime"), 0, 1000);
- // don't sleep when BackgroundYieldTime set to 0, since this will still yield to other threads
- // of equal priority on Windows
- if (milliseconds_to_sleep > 0)
- {
- ms_sleep(milliseconds_to_sleep);
- // also pause worker threads during this wait period
- LLAppViewer::getTextureCache()->pause();
- LLAppViewer::getImageDecodeThread()->pause();
- }
+ LL_RECORD_BLOCK_TIME(FTM_VFS);
+ io_pending += LLVFSThread::updateClass(1);
}
-
- if (mRandomizeFramerate)
{
- ms_sleep(rand() % 200);
+ LL_RECORD_BLOCK_TIME(FTM_LFS);
+ io_pending += LLLFSThread::updateClass(1);
}
- if (mPeriodicSlowFrame
- && (gFrameCount % 10 == 0))
+ if (io_pending > 1000)
{
- LL_INFOS() << "Periodic slow frame - sleeping 500 ms" << LL_ENDL;
- ms_sleep(500);
+ ms_sleep(llmin(io_pending/100,100)); // give the vfs some time to catch up
}
- const F64Milliseconds max_idle_time = llmin(.005f*10.f*(F32Milliseconds)gFrameTimeSeconds, F32Milliseconds(5)); // 5 ms a second
- idleTimer.reset();
- S32 total_work_pending = 0;
- S32 total_io_pending = 0;
- while(1)
- {
- S32 work_pending = 0;
- S32 io_pending = 0;
- F32 max_time = llmin(gFrameIntervalSeconds.value() *10.f, 1.f);
-
- work_pending += updateTextureThreads(max_time);
-
- {
- LL_RECORD_BLOCK_TIME(FTM_VFS);
- io_pending += LLVFSThread::updateClass(1);
- }
- {
- LL_RECORD_BLOCK_TIME(FTM_LFS);
- io_pending += LLLFSThread::updateClass(1);
- }
-
- if (io_pending > 1000)
- {
- ms_sleep(llmin(io_pending/100,100)); // give the vfs some time to catch up
- }
-
- total_work_pending += work_pending ;
- total_io_pending += io_pending ;
-
- if (!work_pending || idleTimer.getElapsedTimeF64() >= max_idle_time)
- {
- break;
- }
- }
- gMeshRepo.update() ;
+ total_work_pending += work_pending ;
+ total_io_pending += io_pending ;
- if(!total_work_pending) //pause texture fetching threads if nothing to process.
- {
- LLAppViewer::getTextureCache()->pause();
- LLAppViewer::getImageDecodeThread()->pause();
- LLAppViewer::getTextureFetch()->pause();
- }
- if(!total_io_pending) //pause file threads if nothing to process.
- {
- LLVFSThread::sLocal->pause();
- LLLFSThread::sLocal->pause();
- }
-
- //texture fetching debugger
- if(LLTextureFetchDebugger::isEnabled())
+ if (!work_pending || idleTimer.getElapsedTimeF64() >= max_idle_time)
{
- LLFloaterTextureFetchDebugger* tex_fetch_debugger_instance =
- LLFloaterReg::findTypedInstance<LLFloaterTextureFetchDebugger>("tex_fetch_debugger");
- if(tex_fetch_debugger_instance)
- {
- tex_fetch_debugger_instance->idle() ;
- }
+ break;
}
+ }
+ gMeshRepo.update() ;
+
+ if(!total_work_pending) //pause texture fetching threads if nothing to process.
+ {
+ LLAppViewer::getTextureCache()->pause();
+ LLAppViewer::getImageDecodeThread()->pause();
+ LLAppViewer::getTextureFetch()->pause();
+ }
+ if(!total_io_pending) //pause file threads if nothing to process.
+ {
+ LLVFSThread::sLocal->pause();
+ LLLFSThread::sLocal->pause();
+ }
- if ((LLStartUp::getStartupState() >= STATE_CLEANUP) &&
- (frameTimer.getElapsedTimeF64() > FRAME_STALL_THRESHOLD))
+ //texture fetching debugger
+ if(LLTextureFetchDebugger::isEnabled())
+ {
+ LLFloaterTextureFetchDebugger* tex_fetch_debugger_instance =
+ LLFloaterReg::findTypedInstance<LLFloaterTextureFetchDebugger>("tex_fetch_debugger");
+ if(tex_fetch_debugger_instance)
{
- gFrameStalls++;
+ tex_fetch_debugger_instance->idle() ;
}
- frameTimer.reset();
-
- resumeMainloopTimeout();
-
- pingMainloopTimeout("Main:End");
- }
- }
- catch(std::bad_alloc)
- {
- LLMemory::logMemoryInfo(TRUE) ;
+ }
- //stop memory leaking simulation
- LLFloaterMemLeak* mem_leak_instance =
- LLFloaterReg::findTypedInstance<LLFloaterMemLeak>("mem_leaking");
- if(mem_leak_instance)
+ if ((LLStartUp::getStartupState() >= STATE_CLEANUP) &&
+ (frameTimer.getElapsedTimeF64() > FRAME_STALL_THRESHOLD))
{
- mem_leak_instance->stop() ;
- LL_WARNS() << "Bad memory allocation in LLAppViewer::mainLoop()!" << LL_ENDL ;
+ gFrameStalls++;
}
- else
- {
- //output possible call stacks to log file.
- LLError::LLCallStacks::print() ;
+ frameTimer.reset();
- LL_ERRS() << "Bad memory allocation in LLAppViewer::mainLoop()!" << LL_ENDL ;
- }
+ resumeMainloopTimeout();
+
+ pingMainloopTimeout("Main:End");
+ }
+ }
+ catch(std::bad_alloc)
+ {
+ LLMemory::logMemoryInfo(TRUE) ;
+
+ //stop memory leaking simulation
+ LLFloaterMemLeak* mem_leak_instance =
+ LLFloaterReg::findTypedInstance<LLFloaterMemLeak>("mem_leaking");
+ if(mem_leak_instance)
+ {
+ mem_leak_instance->stop() ;
+ LL_WARNS() << "Bad memory allocation in LLAppViewer::frame()!" << LL_ENDL ;
+ }
+ else
+ {
+ //output possible call stacks to log file.
+ LLError::LLCallStacks::print() ;
+
+ LL_ERRS() << "Bad memory allocation in LLAppViewer::frame()!" << LL_ENDL ;
}
}
@@ -1620,7 +1593,7 @@ bool LLAppViewer::mainLoop()
LL_INFOS() << "Exiting main_loop" << LL_ENDL;
}
- return LLApp::isExiting();
+ return ! LLApp::isRunning();
}
S32 LLAppViewer::updateTextureThreads(F32 max_time)
@@ -5548,8 +5521,7 @@ void LLAppViewer::forceErrorInfiniteLoop()
void LLAppViewer::forceErrorSoftwareException()
{
LL_WARNS() << "Forcing a deliberate exception" << LL_ENDL;
- // *FIX: Any way to insure it won't be handled?
- throw;
+ BOOST_THROW_EXCEPTION(LLException("User selected Force Software Exception"));
}
void LLAppViewer::forceErrorDriverCrash()
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index b5e674bd7b..f7c1bb58b4 100644
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -79,7 +79,7 @@ public:
//
virtual bool init(); // Override to do application initialization
virtual bool cleanup(); // Override to do application cleanup
- virtual bool mainLoop(); // Override for the application main loop. Needs to at least gracefully notice the QUITTING state and exit.
+ virtual bool frame(); // Override for application body logic
// Application control
void flushVFSIO(); // waits for vfs transfers to complete
@@ -283,7 +283,6 @@ private:
std::string mSerialNumber;
bool mPurgeCache;
bool mPurgeOnExit;
- bool mMainLoopInitialized;
LLViewerJoystick* joystick;
bool mSavedFinalSnapshot;
diff --git a/indra/newview/llappviewerlinux.cpp b/indra/newview/llappviewerlinux.cpp
index f5742b29cf..6f32aab851 100644
--- a/indra/newview/llappviewerlinux.cpp
+++ b/indra/newview/llappviewerlinux.cpp
@@ -95,10 +95,8 @@ int main( int argc, char **argv )
}
// Run the application main loop
- if(!LLApp::isQuitting())
- {
- viewer_app_ptr->mainLoop();
- }
+ while (! viewer_app_ptr->frame())
+ {}
if (!LLApp::isError())
{
diff --git a/indra/newview/llappviewermacosx.cpp b/indra/newview/llappviewermacosx.cpp
index ca219fda59..4fe1e31668 100644
--- a/indra/newview/llappviewermacosx.cpp
+++ b/indra/newview/llappviewermacosx.cpp
@@ -117,12 +117,17 @@ void handleQuit()
LLAppViewer::instance()->userQuit();
}
-bool runMainLoop()
+// This function is called pumpMainLoop() rather than runMainLoop() because
+// it passes control to the viewer's main-loop logic for a single frame. Like
+// LLAppViewer::frame(), it returns 'true' when it's done. Until then, it
+// expects to be called again by the timer in LLAppDelegate
+// (llappdelegate-objc.mm).
+bool pumpMainLoop()
{
bool ret = LLApp::isQuitting();
if (!ret && gViewerAppPtr != NULL)
{
- ret = gViewerAppPtr->mainLoop();
+ ret = gViewerAppPtr->frame();
} else {
ret = true;
}
diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp
index 4786f83bfd..a7f248ab5a 100644
--- a/indra/newview/llappviewerwin32.cpp
+++ b/indra/newview/llappviewerwin32.cpp
@@ -317,10 +317,8 @@ int APIENTRY WINMAIN(HINSTANCE hInstance,
}
// Run the application main loop
- if(!LLApp::isQuitting())
- {
- viewer_app_ptr->mainLoop();
- }
+ while (! viewer_app_ptr->frame())
+ {}
if (!LLApp::isError())
{
diff --git a/indra/newview/llcommandlineparser.cpp b/indra/newview/llcommandlineparser.cpp
index 1819fc74ee..54f96b8872 100644
--- a/indra/newview/llcommandlineparser.cpp
+++ b/indra/newview/llcommandlineparser.cpp
@@ -26,6 +26,7 @@
#include "llviewerprecompiledheaders.h"
#include "llcommandlineparser.h"
+#include "llexception.h"
// *NOTE: The boost::lexical_cast generates
// the warning C4701(local used with out assignment) in VC7.1.
@@ -42,6 +43,7 @@
#include <boost/bind.hpp>
#include <boost/tokenizer.hpp>
#include <boost/assign/list_of.hpp>
+#include <boost/throw_exception.hpp>
#if _MSC_VER
# pragma warning(pop)
@@ -98,14 +100,14 @@ namespace
bool gPastLastOption = false;
}
-class LLCLPError : public std::logic_error {
+class LLCLPError : public LLException {
public:
- LLCLPError(const std::string& what) : std::logic_error(what) {}
+ LLCLPError(const std::string& what) : LLException(what) {}
};
-class LLCLPLastOption : public std::logic_error {
+class LLCLPLastOption : public LLException {
public:
- LLCLPLastOption(const std::string& what) : std::logic_error(what) {}
+ LLCLPLastOption(const std::string& what) : LLException(what) {}
};
class LLCLPValue : public po::value_semantic_codecvt_helper<char>
@@ -202,17 +204,17 @@ protected:
{
if(gPastLastOption)
{
- throw(LLCLPLastOption("Don't parse no more!"));
+ BOOST_THROW_EXCEPTION(LLCLPLastOption("Don't parse no more!"));
}
// Error checks. Needed?
if (!value_store.empty() && !is_composing())
{
- throw(LLCLPError("Non composing value with multiple occurences."));
+ BOOST_THROW_EXCEPTION(LLCLPError("Non composing value with multiple occurences."));
}
if (new_tokens.size() < min_tokens() || new_tokens.size() > max_tokens())
{
- throw(LLCLPError("Illegal number of tokens specified."));
+ BOOST_THROW_EXCEPTION(LLCLPError("Illegal number of tokens specified."));
}
if(value_store.empty())
@@ -466,7 +468,7 @@ onevalue(const std::string& option,
{
// What does it mean when the user specifies a command-line switch
// that requires a value, but omits the value? Complain.
- throw LLCLPError(STRINGIZE("No value specified for --" << option << "!"));
+ BOOST_THROW_EXCEPTION(LLCLPError(STRINGIZE("No value specified for --" << option << "!")));
}
else if (value.size() > 1)
{
@@ -484,9 +486,10 @@ void badvalue(const std::string& option,
// If the user passes an unusable value for a command-line switch, it
// seems like a really bad idea to just ignore it, even with a log
// warning.
- throw LLCLPError(STRINGIZE("Invalid value specified by command-line switch '" << option
- << "' for variable '" << varname << "' of type " << type
- << ": '" << value << "'"));
+ BOOST_THROW_EXCEPTION(
+ LLCLPError(STRINGIZE("Invalid value specified by command-line switch '" << option
+ << "' for variable '" << varname << "' of type " << type
+ << ": '" << value << "'")));
}
template <typename T>
diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp
index 7721e67290..76e16f5a1f 100644
--- a/indra/newview/llcompilequeue.cpp
+++ b/indra/newview/llcompilequeue.cpp
@@ -67,7 +67,9 @@ namespace
const std::string QUEUE_EVENTPUMP_NAME("ScriptActionQueue");
-
+ // ObjectIventoryFetcher is an adapter between the LLVOInventoryListener::inventoryChanged
+ // callback mechanism and the LLEventPump coroutine architecture allowing the
+ // coroutine to wait for the inventory event.
class ObjectInventoryFetcher: public LLVOInventoryListener
{
public:
@@ -144,7 +146,7 @@ public:
queue->getChild<LLScrollListCtrl>("queue output")->addSimpleElement(message, ADD_BOTTOM);
}
- return LLSD().with("success", LLSD::Boolean(true));
+ return LLSDMap("success", LLSD::Boolean(true));
}
@@ -254,7 +256,6 @@ LLFloaterCompileQueue::LLFloaterCompileQueue(const LLSD& key)
setTitle(LLTrans::getString("CompileQueueTitle"));
setStartString(LLTrans::getString("CompileQueueStart"));
-// mUploadQueue = new LLAssetUploadQueue(new LLCompileFloaterUploadQueueSupplier(key.asUUID()));
}
LLFloaterCompileQueue::~LLFloaterCompileQueue()
@@ -267,7 +268,6 @@ void LLFloaterCompileQueue::experienceIdsReceived( const LLSD& content )
{
mExperienceIds.insert(it->asUUID());
}
-// nextObject();
}
BOOL LLFloaterCompileQueue::hasExperience( const LLUUID& id ) const
@@ -277,11 +277,6 @@ BOOL LLFloaterCompileQueue::hasExperience( const LLUUID& id ) const
// //Attempt to record this asset ID. If it can not be inserted into the set
// //then it has already been processed so return false.
-// bool LLFloaterCompileQueue::checkAssetId(const LLUUID &assetId)
-// {
-// std::pair<uuid_list_t::iterator, bool> result = mAssetIds.insert(assetId);
-// return result.second;
-// }
void LLFloaterCompileQueue::handleHTTPResponse(std::string pumpName, const LLSD &expresult)
{
@@ -331,8 +326,10 @@ void LLFloaterCompileQueue::processExperienceIdResults(LLSD result, LLUUID paren
queue->experienceIdsReceived(result["experience_ids"]);
+ // getDerived handle gets a handle that can be resolved to a parent class of the derived object.
LLHandle<LLFloaterScriptQueue> hFloater(queue->getDerivedHandle<LLFloaterScriptQueue>());
+ // note subtle difference here: getDerivedHandle in this case is for an LLFloaterCompileQueue
fnQueueAction_t fn = boost::bind(LLFloaterCompileQueue::processScript,
queue->getDerivedHandle<LLFloaterCompileQueue>(), _1, _2, _3);
@@ -345,37 +342,35 @@ void LLFloaterCompileQueue::processExperienceIdResults(LLSD result, LLUUID paren
}
+/// This is a utility function to be bound and called from objectScriptProcessingQueueCoro.
+/// Do not call directly. It may throw a LLCheckedHandle<>::Stale exception.
bool LLFloaterCompileQueue::processScript(LLHandle<LLFloaterCompileQueue> hfloater,
const LLPointer<LLViewerObject> &object, LLInventoryObject* inventory, LLEventPump &pump)
{
LLSD result;
- LLFloaterCompileQueue *that = hfloater.get();
- bool monocompile = that->mMono;
+ LLCheckedHandle<LLFloaterCompileQueue> floater(hfloater);
+ // Dereferencing floater may fail. If they do they throw LLExeceptionStaleHandle.
+ // which is caught in objectScriptProcessingQueueCoro
+ bool monocompile = floater->mMono;
F32 fetch_timeout = gSavedSettings.getF32("QueueInventoryFetchTimeout");
- if (!that)
- return false;
// Initial test to see if we can (or should) attempt to compile the script.
LLInventoryItem *item = dynamic_cast<LLInventoryItem *>(inventory);
- {
- if (!item->getPermissions().allowModifyBy(gAgent.getID(), gAgent.getGroupID()) ||
- !item->getPermissions().allowCopyBy(gAgent.getID(), gAgent.getGroupID()))
- {
- std::string buffer = "Skipping: " + item->getName() + "(Permissions)";
- that->addStringMessage(buffer);
- return true;
- }
+ if (!item)
+ {
+ LL_WARNS("SCRIPTQ") << "item retrieved is not an LLInventoryItem." << LL_ENDL;
+ return true;
+ }
-// if (!that->checkAssetId(item->getAssetUUID()))
-// {
-// std::string buffer = "Skipping: " + item->getName() + "(Repeat)";
-// that->addStringMessage(buffer);
-// return true;
-// }
+ if (!item->getPermissions().allowModifyBy(gAgent.getID(), gAgent.getGroupID()) ||
+ !item->getPermissions().allowCopyBy(gAgent.getID(), gAgent.getGroupID()))
+ {
+ std::string buffer = "Skipping: " + item->getName() + "(Permissions)";
+ floater->addStringMessage(buffer);
+ return true;
}
- that = NULL;
// Attempt to retrieve the experience
LLUUID experienceId;
@@ -384,37 +379,30 @@ bool LLFloaterCompileQueue::processScript(LLHandle<LLFloaterCompileQueue> hfloat
boost::bind(&LLFloaterCompileQueue::handleHTTPResponse, pump.getName(), _1));
result = llcoro::suspendUntilEventOnWithTimeout(pump, fetch_timeout,
- LLSD().with("timeout", LLSD::Boolean(true)));
+ LLSDMap("timeout", LLSD::Boolean(true)));
- that = hfloater.get();
- if (!that)
- {
- return false;
- }
-
- if (result.has("timeout") && result["timeout"].asBoolean())
- {
+ if (result.has("timeout"))
+ { // A timeout filed in the result will always be true if present.
LLStringUtil::format_map_t args;
args["[OBJECT_NAME]"] = inventory->getName();
- std::string buffer = that->getString("Timeout", args);
- that->addStringMessage(buffer);
+ std::string buffer = floater->getString("Timeout", args);
+ floater->addStringMessage(buffer);
return true;
}
if (result.has(LLExperienceCache::EXPERIENCE_ID))
{
experienceId = result[LLExperienceCache::EXPERIENCE_ID].asUUID();
- if (!that->hasExperience(experienceId))
+ if (!floater->hasExperience(experienceId))
{
- that->addProcessingMessage("CompileNoExperiencePerm", LLSD()
- .with("SCRIPT", inventory->getName())
- .with("EXPERIENCE", result[LLExperienceCache::NAME].asString()));
+ floater->addProcessingMessage("CompileNoExperiencePerm",
+ LLSDMap("SCRIPT", inventory->getName())
+ ("EXPERIENCE", result[LLExperienceCache::NAME].asString()));
return true;
}
}
}
- that = NULL;
{
HandleScriptUserData userData(pump.getName());
@@ -433,32 +421,23 @@ bool LLFloaterCompileQueue::processScript(LLHandle<LLFloaterCompileQueue> hfloat
&userData);
result = llcoro::suspendUntilEventOnWithTimeout(pump, fetch_timeout,
- LLSD().with("timeout", LLSD::Boolean(true)));
- }
-
- that = hfloater.get();
- if (!that)
- {
- return false;
+ LLSDMap("timeout", LLSD::Boolean(true)));
}
if (result.has("timeout"))
- {
- if (result.has("timeout") && result["timeout"].asBoolean())
- {
- LLStringUtil::format_map_t args;
- args["[OBJECT_NAME]"] = inventory->getName();
- std::string buffer = that->getString("Timeout", args);
- that->addStringMessage(buffer);
- return true;
- }
+ { // A timeout filed in the result will always be true if present.
+ LLStringUtil::format_map_t args;
+ args["[OBJECT_NAME]"] = inventory->getName();
+ std::string buffer = floater->getString("Timeout", args);
+ floater->addStringMessage(buffer);
+ return true;
}
if (result.has("error"))
{
LL_WARNS("SCRIPTQ") << "Inventory fetch returned with error. Code: " << result["error"].asString() << LL_ENDL;
std::string buffer = result["message"].asString() + " " + inventory->getName();
- that->addStringMessage(buffer);
+ floater->addStringMessage(buffer);
if (result.has("alert"))
{
@@ -470,12 +449,9 @@ bool LLFloaterCompileQueue::processScript(LLHandle<LLFloaterCompileQueue> hfloat
}
LLUUID assetId = result["asset_id"];
- that = NULL;
-
std::string url = object->getRegion()->getCapability("UpdateScriptTask");
-
{
LLResourceUploadInfo::ptr_t uploadInfo(new LLQueuedScriptAssetUpload(object->getID(),
inventory->getUUID(),
@@ -490,24 +466,15 @@ bool LLFloaterCompileQueue::processScript(LLHandle<LLFloaterCompileQueue> hfloat
LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo);
}
- result = llcoro::suspendUntilEventOnWithTimeout(pump, fetch_timeout, LLSD().with("timeout", LLSD::Boolean(true)));
-
- that = hfloater.get();
- if (!that)
- {
- return false;
- }
+ result = llcoro::suspendUntilEventOnWithTimeout(pump, fetch_timeout, LLSDMap("timeout", LLSD::Boolean(true)));
if (result.has("timeout"))
- {
- if (result.has("timeout") && result["timeout"].asBoolean())
- {
- LLStringUtil::format_map_t args;
- args["[OBJECT_NAME]"] = inventory->getName();
- std::string buffer = that->getString("Timeout", args);
- that->addStringMessage(buffer);
- return true;
- }
+ { // A timeout filed in the result will always be true if present.
+ LLStringUtil::format_map_t args;
+ args["[OBJECT_NAME]"] = inventory->getName();
+ std::string buffer = floater->getString("Timeout", args);
+ floater->addStringMessage(buffer);
+ return true;
}
// Bytecode save completed
@@ -515,21 +482,21 @@ bool LLFloaterCompileQueue::processScript(LLHandle<LLFloaterCompileQueue> hfloat
{
std::string buffer = std::string("Compilation of \"") + inventory->getName() + std::string("\" succeeded");
- that->addStringMessage(buffer);
+ floater->addStringMessage(buffer);
LL_INFOS() << buffer << LL_ENDL;
}
else
{
LLSD compile_errors = result["errors"];
std::string buffer = std::string("Compilation of \"") + inventory->getName() + std::string("\" failed:");
- that->addStringMessage(buffer);
+ floater->addStringMessage(buffer);
for (LLSD::array_const_iterator line = compile_errors.beginArray();
line < compile_errors.endArray(); line++)
{
std::string str = line->asString();
str.erase(std::remove(str.begin(), str.end(), '\n'), str.end());
- that->addStringMessage(str);
+ floater->addStringMessage(str);
}
LL_INFOS() << result["errors"] << LL_ENDL;
}
@@ -576,16 +543,18 @@ LLFloaterResetQueue::~LLFloaterResetQueue()
{
}
-bool LLFloaterResetQueue::resetObjectScripts(LLHandle<LLFloaterScriptQueue> hfloater,
+/// This is a utility function to be bound and called from objectScriptProcessingQueueCoro.
+/// Do not call directly. It may throw a LLCheckedHandle<>::Stale exception.
+bool LLFloaterResetQueue::resetObjectScripts(LLHandle<LLFloaterScriptQueue> hfloater,
const LLPointer<LLViewerObject> &object, LLInventoryObject* inventory, LLEventPump &pump)
{
- LLFloaterScriptQueue *that = hfloater.get();
- if (that)
- {
- std::string buffer;
- buffer = that->getString("Resetting") + (": ") + inventory->getName();
- that->addStringMessage(buffer);
- }
+ LLCheckedHandle<LLFloaterScriptQueue> floater(hfloater);
+ // Dereferencing floater may fail. If they do they throw LLExeceptionStaleHandle.
+ // which is caught in objectScriptProcessingQueueCoro
+
+ std::string buffer;
+ buffer = floater->getString("Resetting") + (": ") + inventory->getName();
+ floater->addStringMessage(buffer);
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_ScriptReset);
@@ -602,6 +571,8 @@ bool LLFloaterResetQueue::resetObjectScripts(LLHandle<LLFloaterScriptQueue> hflo
bool LLFloaterResetQueue::startQueue()
{
+ // Bind the resetObjectScripts method into a QueueAction function and pass it
+ // into the object queue processing coroutine.
fnQueueAction_t fn = boost::bind(LLFloaterResetQueue::resetObjectScripts,
getDerivedHandle<LLFloaterScriptQueue>(), _1, _2, _3);
@@ -629,16 +600,18 @@ LLFloaterRunQueue::~LLFloaterRunQueue()
{
}
-bool LLFloaterRunQueue::runObjectScripts(LLHandle<LLFloaterScriptQueue> hfloater,
+/// This is a utility function to be bound and called from objectScriptProcessingQueueCoro.
+/// Do not call directly. It may throw a LLCheckedHandle<>::Stale exception.
+bool LLFloaterRunQueue::runObjectScripts(LLHandle<LLFloaterScriptQueue> hfloater,
const LLPointer<LLViewerObject> &object, LLInventoryObject* inventory, LLEventPump &pump)
{
- LLFloaterScriptQueue *that = hfloater.get();
- if (that)
- {
- std::string buffer;
- buffer = that->getString("Running") + (": ") + inventory->getName();
- that->addStringMessage(buffer);
- }
+ LLCheckedHandle<LLFloaterScriptQueue> floater(hfloater);
+ // Dereferencing floater may fail. If they do they throw LLExeceptionStaleHandle.
+ // which is caught in objectScriptProcessingQueueCoro
+
+ std::string buffer;
+ buffer = floater->getString("Running") + (": ") + inventory->getName();
+ floater->addStringMessage(buffer);
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_SetScriptRunning);
@@ -684,16 +657,18 @@ LLFloaterNotRunQueue::~LLFloaterNotRunQueue()
{
}
+/// This is a utility function to be bound and called from objectScriptProcessingQueueCoro.
+/// Do not call directly. It may throw a LLCheckedHandle<>::Stale exception.
bool LLFloaterNotRunQueue::stopObjectScripts(LLHandle<LLFloaterScriptQueue> hfloater,
const LLPointer<LLViewerObject> &object, LLInventoryObject* inventory, LLEventPump &pump)
{
- LLFloaterScriptQueue *that = hfloater.get();
- if (that)
- {
- std::string buffer;
- buffer = that->getString("NotRunning") + (": ") + inventory->getName();
- that->addStringMessage(buffer);
- }
+ LLCheckedHandle<LLFloaterScriptQueue> floater(hfloater);
+ // Dereferencing floater may fail. If they do they throw LLExeceptionStaleHandle.
+ // which is caught in objectScriptProcessingQueueCoro
+
+ std::string buffer;
+ buffer = floater->getString("NotRunning") + (": ") + inventory->getName();
+ floater->addStringMessage(buffer);
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_SetScriptRunning);
@@ -732,7 +707,7 @@ void ObjectInventoryFetcher::inventoryChanged(LLViewerObject* object,
mInventoryList.clear();
mInventoryList.assign(inventory->begin(), inventory->end());
- mPump.post(LLSD().with("changed", LLSD::Boolean(true)));
+ mPump.post(LLSDMap("changed", LLSD::Boolean(true)));
}
@@ -740,115 +715,97 @@ void LLFloaterScriptQueue::objectScriptProcessingQueueCoro(std::string action, L
object_data_list_t objectList, fnQueueAction_t func)
{
LLCoros::set_consuming(true);
- LLFloaterScriptQueue * floater(NULL);
+ LLCheckedHandle<LLFloaterScriptQueue> floater(hfloater);
+ // Dereferencing floater may fail. If they do they throw LLExeceptionStaleHandle.
+ // This is expected if the dialog closes.
LLEventMailDrop maildrop(QUEUE_EVENTPUMP_NAME, true);
F32 fetch_timeout = gSavedSettings.getF32("QueueInventoryFetchTimeout");
-// floater = hfloater.get();
-// floater->addProcessingMessage("Starting",
-// LLSD()
-// .with("[START]", action)
-// .with("[COUNT]", LLSD::Integer(objectList.size())));
-// floater = NULL;
- for (object_data_list_t::iterator itObj(objectList.begin()); (itObj != objectList.end()); ++itObj)
+ try
{
- bool firstForObject = true;
- LLUUID object_id = (*itObj).mObjectId;
- LL_INFOS("SCRIPTQ") << "Next object in queue with ID=" << object_id.asString() << LL_ENDL;
-
- LLPointer<LLViewerObject> obj = gObjectList.findObject(object_id);
- LLInventoryObject::object_list_t inventory;
- if (obj)
+ for (object_data_list_t::iterator itObj(objectList.begin()); (itObj != objectList.end()); ++itObj)
{
- ObjectInventoryFetcher::ptr_t fetcher(new ObjectInventoryFetcher(maildrop, obj, NULL));
+ bool firstForObject = true;
+ LLUUID object_id = (*itObj).mObjectId;
+ LL_INFOS("SCRIPTQ") << "Next object in queue with ID=" << object_id.asString() << LL_ENDL;
- fetcher->fetchInventory();
-
- floater = hfloater.get();
- if (floater)
+ LLPointer<LLViewerObject> obj = gObjectList.findObject(object_id);
+ LLInventoryObject::object_list_t inventory;
+ if (obj)
{
+ ObjectInventoryFetcher::ptr_t fetcher(new ObjectInventoryFetcher(maildrop, obj, NULL));
+
+ fetcher->fetchInventory();
+
LLStringUtil::format_map_t args;
args["[OBJECT_NAME]"] = (*itObj).mObjectName;
floater->addStringMessage(floater->getString("LoadingObjInv", args));
- }
- LLSD result = llcoro::suspendUntilEventOnWithTimeout(maildrop, fetch_timeout,
- LLSD().with("timeout", LLSD::Boolean(true)));
+ LLSD result = llcoro::suspendUntilEventOnWithTimeout(maildrop, fetch_timeout,
+ LLSDMap("timeout", LLSD::Boolean(true)));
- if (result.has("timeout") && result["timeout"].asBoolean())
- {
- LL_WARNS("SCRIPTQ") << "Unable to retrieve inventory for object " << object_id.asString() <<
- ". Skipping to next object." << LL_ENDL;
+ if (result.has("timeout"))
+ { // A timeout filed in the result will always be true if present.
+ LL_WARNS("SCRIPTQ") << "Unable to retrieve inventory for object " << object_id.asString() <<
+ ". Skipping to next object." << LL_ENDL;
- // floater could have been closed
- floater = hfloater.get();
- if (floater)
- {
LLStringUtil::format_map_t args;
args["[OBJECT_NAME]"] = (*itObj).mObjectName;
floater->addStringMessage(floater->getString("Timeout", args));
+
+ continue;
}
+ inventory.assign(fetcher->getInventoryList().begin(), fetcher->getInventoryList().end());
+ }
+ else
+ {
+ LL_WARNS("SCRIPTQ") << "Unable to retrieve object with ID of " << object_id <<
+ ". Skipping to next." << LL_ENDL;
continue;
}
- inventory.assign(fetcher->getInventoryList().begin(), fetcher->getInventoryList().end());
- }
- else
- {
- LL_WARNS("SCRIPTQ") << "Unable to retrieve object with ID of " << object_id <<
- ". Skipping to next." << LL_ENDL;
- continue;
- }
+ // TODO: Get the name of the object we are looking at here so that we can display it below.
+ //std::string objName = (dynamic_cast<LLInventoryObject *>(obj.get()))->getName();
+ LL_DEBUGS("SCRIPTQ") << "Object has " << inventory.size() << " items." << LL_ENDL;
- // TODO: Get the name of the object we are looking at here so that we can display it below.
- //std::string objName = (dynamic_cast<LLInventoryObject *>(obj.get()))->getName();
- LL_DEBUGS("SCRIPTQ") << "Object has " << inventory.size() << " items." << LL_ENDL;
-
- for (LLInventoryObject::object_list_t::iterator itInv = inventory.begin();
- itInv != inventory.end(); ++itInv)
- {
- floater = hfloater.get();
- if (!floater)
+ for (LLInventoryObject::object_list_t::iterator itInv = inventory.begin();
+ itInv != inventory.end(); ++itInv)
{
- LL_WARNS("SCRIPTQ") << "Script Queue floater closed! Canceling remaining ops" << LL_ENDL;
- break;
- }
+ floater.check();
- // note, we have a smart pointer to the obj above... but if we didn't we'd check that
- // it still exists here.
+ // note, we have a smart pointer to the obj above... but if we didn't we'd check that
+ // it still exists here.
- if (((*itInv)->getType() == LLAssetType::AT_LSL_TEXT))
- {
- LL_DEBUGS("SCRIPTQ") << "Inventory item " << (*itInv)->getUUID().asString() << "\"" << (*itInv)->getName() << "\"" << LL_ENDL;
- if (firstForObject)
+ if (((*itInv)->getType() == LLAssetType::AT_LSL_TEXT))
{
- //floater->addStringMessage(objName + ":");
- firstForObject = false;
+ LL_DEBUGS("SCRIPTQ") << "Inventory item " << (*itInv)->getUUID().asString() << "\"" << (*itInv)->getName() << "\"" << LL_ENDL;
+ if (firstForObject)
+ {
+ //floater->addStringMessage(objName + ":");
+ firstForObject = false;
+ }
+
+ if (!func(obj, (*itInv), maildrop))
+ {
+ continue;
+ }
}
- if (!func(obj, (*itInv), maildrop))
- {
- continue;
- }
+ // no other explicit suspension point in this loop. func(...) MIGHT suspend
+ // but offers no guarantee of doing so.
+ llcoro::suspend();
}
-
- llcoro::suspend();
- }
- // Just test to be sure the floater is still present before calling the func
- if (!hfloater.get())
- {
- LL_WARNS("SCRIPTQ") << "Script Queue floater dismissed." << LL_ENDL;
- break;
}
- }
-
- floater = hfloater.get();
- if (floater)
- {
floater->addStringMessage("Done");
floater->getChildView("close")->setEnabled(TRUE);
}
+ catch (LLCheckedHandleBase::Stale &)
+ {
+ // This is expected. It means that floater has been closed before
+ // processing was completed.
+ LL_DEBUGS("SCRIPTQ") << "LLExeceptionStaleHandle caught! Floater has most likely been closed." << LL_ENDL;
+ }
}
diff --git a/indra/newview/llsecapi.cpp b/indra/newview/llsecapi.cpp
index 4f9f83b6f2..bcb9417820 100644
--- a/indra/newview/llsecapi.cpp
+++ b/indra/newview/llsecapi.cpp
@@ -29,6 +29,7 @@
#include "llviewerprecompiledheaders.h"
#include "llsecapi.h"
#include "llsechandler_basic.h"
+#include <boost/throw_exception.hpp>
#include <openssl/evp.h>
#include <openssl/err.h>
#include <map>
@@ -64,12 +65,12 @@ void initializeSecHandler()
}
catch (LLProtectedDataException e)
{
- exception_msg = e.getMessage();
+ exception_msg = e.what();
}
}
if (!exception_msg.empty()) // an exception was thrown.
{
- throw LLProtectedDataException(exception_msg.c_str());
+ BOOST_THROW_EXCEPTION(LLProtectedDataException(exception_msg));
}
}
diff --git a/indra/newview/llsecapi.h b/indra/newview/llsecapi.h
index 6fe3ee31cf..6af5a28fa5 100644
--- a/indra/newview/llsecapi.h
+++ b/indra/newview/llsecapi.h
@@ -32,6 +32,7 @@
#include <openssl/x509.h>
#include <ostream>
#include "llpointer.h"
+#include "llexception.h"
#ifdef LL_WINDOWS
#pragma warning(disable:4250)
@@ -116,17 +117,13 @@
-class LLProtectedDataException
+struct LLProtectedDataException: public LLException
{
-public:
- LLProtectedDataException(const char *msg)
+ LLProtectedDataException(const std::string& msg):
+ LLException(msg)
{
- LL_WARNS("SECAPI") << "Protected Data Error: " << (std::string)msg << LL_ENDL;
- mMsg = (std::string)msg;
+ LL_WARNS("SECAPI") << "Protected Data Error: " << msg << LL_ENDL;
}
- std::string getMessage() { return mMsg; }
-protected:
- std::string mMsg;
};
// class LLCertificate
@@ -334,22 +331,21 @@ std::ostream& operator <<(std::ostream& s, const LLCredential& cred);
// All error handling is via exceptions.
-class LLCertException
+class LLCertException: public LLException
{
public:
- LLCertException(LLPointer<LLCertificate> cert, const char* msg)
+ LLCertException(LLPointer<LLCertificate> cert, const std::string& msg):
+ LLException(msg)
{
mCert = cert;
- LL_WARNS("SECAPI") << "Certificate Error: " << (std::string)msg << LL_ENDL;
- mMsg = (std::string)msg;
+ LL_WARNS("SECAPI") << "Certificate Error: " << msg << LL_ENDL;
}
- LLPointer<LLCertificate> getCert() { return mCert; }
- std::string getMessage() { return mMsg; }
+ virtual ~LLCertException() throw() {}
+ LLPointer<LLCertificate> getCert() const { return mCert; }
protected:
LLPointer<LLCertificate> mCert;
- std::string mMsg;
};
class LLInvalidCertificate : public LLCertException
@@ -358,6 +354,7 @@ public:
LLInvalidCertificate(LLPointer<LLCertificate> cert) : LLCertException(cert, "CertInvalid")
{
}
+ virtual ~LLInvalidCertificate() throw() {}
protected:
};
@@ -367,6 +364,7 @@ public:
LLCertValidationTrustException(LLPointer<LLCertificate> cert) : LLCertException(cert, "CertUntrusted")
{
}
+ virtual ~LLCertValidationTrustException() throw() {}
protected:
};
@@ -378,7 +376,7 @@ public:
{
mHostname = hostname;
}
-
+ virtual ~LLCertValidationHostnameException() throw() {}
std::string getHostname() { return mHostname; }
protected:
std::string mHostname;
@@ -392,6 +390,7 @@ public:
{
mTime = current_time;
}
+ virtual ~LLCertValidationExpirationException() throw() {}
LLDate GetTime() { return mTime; }
protected:
LLDate mTime;
@@ -403,6 +402,7 @@ public:
LLCertKeyUsageValidationException(LLPointer<LLCertificate> cert) : LLCertException(cert, "CertKeyUsage")
{
}
+ virtual ~LLCertKeyUsageValidationException() throw() {}
protected:
};
@@ -412,6 +412,7 @@ public:
LLCertBasicConstraintsValidationException(LLPointer<LLCertificate> cert) : LLCertException(cert, "CertBasicConstraints")
{
}
+ virtual ~LLCertBasicConstraintsValidationException() throw() {}
protected:
};
@@ -421,6 +422,7 @@ public:
LLCertValidationInvalidSignatureException(LLPointer<LLCertificate> cert) : LLCertException(cert, "CertInvalidSignature")
{
}
+ virtual ~LLCertValidationInvalidSignatureException() throw() {}
protected:
};
diff --git a/indra/newview/llsechandler_basic.cpp b/indra/newview/llsechandler_basic.cpp
index 40516f9bbb..39ce64ad0e 100644
--- a/indra/newview/llsechandler_basic.cpp
+++ b/indra/newview/llsechandler_basic.cpp
@@ -35,6 +35,7 @@
#include "llfile.h"
#include "lldir.h"
#include "llviewercontrol.h"
+#include <boost/throw_exception.hpp>
#include <vector>
#include <ios>
#include <openssl/ossl_typ.h>
@@ -72,14 +73,14 @@ LLBasicCertificate::LLBasicCertificate(const std::string& pem_cert)
if(pem_bio == NULL)
{
LL_WARNS("SECAPI") << "Could not allocate an openssl memory BIO." << LL_ENDL;
- throw LLInvalidCertificate(this);
+ BOOST_THROW_EXCEPTION(LLInvalidCertificate(this));
}
mCert = NULL;
PEM_read_bio_X509(pem_bio, &mCert, 0, NULL);
BIO_free(pem_bio);
if (!mCert)
{
- throw LLInvalidCertificate(this);
+ BOOST_THROW_EXCEPTION(LLInvalidCertificate(this));
}
}
@@ -88,7 +89,7 @@ LLBasicCertificate::LLBasicCertificate(X509* pCert)
{
if (!pCert || !pCert->cert_info)
{
- throw LLInvalidCertificate(this);
+ BOOST_THROW_EXCEPTION(LLInvalidCertificate(this));
}
mCert = X509_dup(pCert);
}
@@ -873,22 +874,22 @@ void _validateCert(int validation_policy,
// check basic properties exist in the cert
if(!current_cert_info.has(CERT_SUBJECT_NAME) || !current_cert_info.has(CERT_SUBJECT_NAME_STRING))
{
- throw LLCertException(cert, "Cert doesn't have a Subject Name");
+ BOOST_THROW_EXCEPTION(LLCertException(cert, "Cert doesn't have a Subject Name"));
}
if(!current_cert_info.has(CERT_ISSUER_NAME_STRING))
{
- throw LLCertException(cert, "Cert doesn't have an Issuer Name");
+ BOOST_THROW_EXCEPTION(LLCertException(cert, "Cert doesn't have an Issuer Name"));
}
// check basic properties exist in the cert
if(!current_cert_info.has(CERT_VALID_FROM) || !current_cert_info.has(CERT_VALID_TO))
{
- throw LLCertException(cert, "Cert doesn't have an expiration period");
+ BOOST_THROW_EXCEPTION(LLCertException(cert, "Cert doesn't have an expiration period"));
}
if (!current_cert_info.has(CERT_SHA1_DIGEST))
{
- throw LLCertException(cert, "No SHA1 digest");
+ BOOST_THROW_EXCEPTION(LLCertException(cert, "No SHA1 digest"));
}
if (validation_policy & VALIDATION_POLICY_TIME)
@@ -903,7 +904,7 @@ void _validateCert(int validation_policy,
if((validation_date < current_cert_info[CERT_VALID_FROM].asDate()) ||
(validation_date > current_cert_info[CERT_VALID_TO].asDate()))
{
- throw LLCertValidationExpirationException(cert, validation_date);
+ BOOST_THROW_EXCEPTION(LLCertValidationExpirationException(cert, validation_date));
}
}
if (validation_policy & VALIDATION_POLICY_SSL_KU)
@@ -914,14 +915,14 @@ void _validateCert(int validation_policy,
!(_LLSDArrayIncludesValue(current_cert_info[CERT_KEY_USAGE],
LLSD((std::string)CERT_KU_KEY_ENCIPHERMENT)))))
{
- throw LLCertKeyUsageValidationException(cert);
+ BOOST_THROW_EXCEPTION(LLCertKeyUsageValidationException(cert));
}
// only validate EKU if the cert has it
if(current_cert_info.has(CERT_EXTENDED_KEY_USAGE) && current_cert_info[CERT_EXTENDED_KEY_USAGE].isArray() &&
(!_LLSDArrayIncludesValue(current_cert_info[CERT_EXTENDED_KEY_USAGE],
LLSD((std::string)CERT_EKU_SERVER_AUTH))))
{
- throw LLCertKeyUsageValidationException(cert);
+ BOOST_THROW_EXCEPTION(LLCertKeyUsageValidationException(cert));
}
}
if (validation_policy & VALIDATION_POLICY_CA_KU)
@@ -930,7 +931,7 @@ void _validateCert(int validation_policy,
(!_LLSDArrayIncludesValue(current_cert_info[CERT_KEY_USAGE],
(std::string)CERT_KU_CERT_SIGN)))
{
- throw LLCertKeyUsageValidationException(cert);
+ BOOST_THROW_EXCEPTION(LLCertKeyUsageValidationException(cert));
}
}
@@ -942,13 +943,13 @@ void _validateCert(int validation_policy,
if(!current_cert_info[CERT_BASIC_CONSTRAINTS].has(CERT_BASIC_CONSTRAINTS_CA) ||
!current_cert_info[CERT_BASIC_CONSTRAINTS][CERT_BASIC_CONSTRAINTS_CA])
{
- throw LLCertBasicConstraintsValidationException(cert);
+ BOOST_THROW_EXCEPTION(LLCertBasicConstraintsValidationException(cert));
}
if (current_cert_info[CERT_BASIC_CONSTRAINTS].has(CERT_BASIC_CONSTRAINTS_PATHLEN) &&
((current_cert_info[CERT_BASIC_CONSTRAINTS][CERT_BASIC_CONSTRAINTS_PATHLEN].asInteger() != 0) &&
(depth > current_cert_info[CERT_BASIC_CONSTRAINTS][CERT_BASIC_CONSTRAINTS_PATHLEN].asInteger())))
{
- throw LLCertBasicConstraintsValidationException(cert);
+ BOOST_THROW_EXCEPTION(LLCertBasicConstraintsValidationException(cert));
}
}
}
@@ -1018,7 +1019,7 @@ void LLBasicCertificateStore::validate(int validation_policy,
if(cert_chain->size() < 1)
{
- throw LLCertException(NULL, "No certs in chain");
+ BOOST_THROW_EXCEPTION(LLCertException(NULL, "No certs in chain"));
}
iterator current_cert = cert_chain->begin();
LLSD current_cert_info;
@@ -1033,11 +1034,11 @@ void LLBasicCertificateStore::validate(int validation_policy,
(*current_cert)->getLLSD(current_cert_info);
if(!validation_params.has(CERT_HOSTNAME))
{
- throw LLCertException((*current_cert), "No hostname passed in for validation");
+ BOOST_THROW_EXCEPTION(LLCertException((*current_cert), "No hostname passed in for validation"));
}
if(!current_cert_info.has(CERT_SUBJECT_NAME) || !current_cert_info[CERT_SUBJECT_NAME].has(CERT_NAME_CN))
{
- throw LLInvalidCertificate((*current_cert));
+ BOOST_THROW_EXCEPTION(LLInvalidCertificate((*current_cert)));
}
LL_DEBUGS("SECAPI") << "Validating the hostname " << validation_params[CERT_HOSTNAME].asString() <<
@@ -1054,7 +1055,7 @@ void LLBasicCertificateStore::validate(int validation_policy,
X509* cert_x509 = (*current_cert)->getOpenSSLX509();
if(!cert_x509)
{
- throw LLInvalidCertificate((*current_cert));
+ BOOST_THROW_EXCEPTION(LLInvalidCertificate((*current_cert)));
}
std::string sha1_hash((const char *)cert_x509->sha1_hash, SHA_DIGEST_LENGTH);
X509_free( cert_x509 );
@@ -1075,7 +1076,7 @@ void LLBasicCertificateStore::validate(int validation_policy,
if((validation_date < cache_entry->second.first) ||
(validation_date > cache_entry->second.second))
{
- throw LLCertValidationExpirationException((*current_cert), validation_date);
+ BOOST_THROW_EXCEPTION(LLCertValidationExpirationException((*current_cert), validation_date));
}
}
// successfully found in cache
@@ -1107,7 +1108,7 @@ void LLBasicCertificateStore::validate(int validation_policy,
if(!_verify_signature((*current_cert),
previous_cert))
{
- throw LLCertValidationInvalidSignatureException(previous_cert);
+ BOOST_THROW_EXCEPTION(LLCertValidationInvalidSignatureException(previous_cert));
}
}
_validateCert(local_validation_policy,
@@ -1156,7 +1157,7 @@ void LLBasicCertificateStore::validate(int validation_policy,
if(!_verify_signature((*found_store_cert),
(*current_cert)))
{
- throw LLCertValidationInvalidSignatureException(*current_cert);
+ BOOST_THROW_EXCEPTION(LLCertValidationInvalidSignatureException(*current_cert));
}
// successfully validated.
mTrustedCertCache[sha1_hash] = std::pair<LLDate, LLDate>(from_time, to_time);
@@ -1173,7 +1174,7 @@ void LLBasicCertificateStore::validate(int validation_policy,
if (validation_policy & VALIDATION_POLICY_TRUSTED)
{
// we reached the end without finding a trusted cert.
- throw LLCertValidationTrustException((*cert_chain)[cert_chain->size()-1]);
+ BOOST_THROW_EXCEPTION(LLCertValidationTrustException((*cert_chain)[cert_chain->size()-1]));
}
mTrustedCertCache[sha1_hash] = std::pair<LLDate, LLDate>(from_time, to_time);
@@ -1261,7 +1262,7 @@ void LLSecAPIBasicHandler::_readProtectedData()
protected_data_stream.read((char *)salt, STORE_SALT_SIZE);
if (protected_data_stream.gcount() < STORE_SALT_SIZE)
{
- throw LLProtectedDataException("Config file too short.");
+ BOOST_THROW_EXCEPTION(LLProtectedDataException("Config file too short."));
}
cipher.decrypt(salt, STORE_SALT_SIZE);
@@ -1301,7 +1302,7 @@ void LLSecAPIBasicHandler::_readProtectedData()
if (parser->parse(parse_stream, mProtectedDataMap,
LLSDSerialize::SIZE_UNLIMITED) == LLSDParser::PARSE_FAILURE)
{
- throw LLProtectedDataException("Config file cannot be decrypted.");
+ BOOST_THROW_EXCEPTION(LLProtectedDataException("Config file cannot be decrypted."));
}
}
}
@@ -1372,7 +1373,7 @@ void LLSecAPIBasicHandler::_writeProtectedData()
// EXP-1825 crash in LLSecAPIBasicHandler::_writeProtectedData()
// Decided throwing an exception here was overkill until we figure out why this happens
- //throw LLProtectedDataException("Error writing Protected Data Store");
+ //BOOST_THROW_EXCEPTION(LLProtectedDataException("Error writing Protected Data Store"));
}
try
@@ -1387,7 +1388,7 @@ void LLSecAPIBasicHandler::_writeProtectedData()
// EXP-1825 crash in LLSecAPIBasicHandler::_writeProtectedData()
// Decided throwing an exception here was overkill until we figure out why this happens
- //throw LLProtectedDataException("Could not overwrite protected data store");
+ //BOOST_THROW_EXCEPTION(LLProtectedDataException("Could not overwrite protected data store"));
}
}
catch (...)
@@ -1401,7 +1402,7 @@ void LLSecAPIBasicHandler::_writeProtectedData()
//crash in LLSecAPIBasicHandler::_writeProtectedData()
// Decided throwing an exception here was overkill until we figure out why this happens
- //throw LLProtectedDataException("Error writing Protected Data Store");
+ //BOOST_THROW_EXCEPTION(LLProtectedDataException("Error writing Protected Data Store"));
}
}