From e5dae42252432d5a6d4453a767b1c3a9508deb32 Mon Sep 17 00:00:00 2001
From: Aura Linden <aura@lindenlab.com>
Date: Mon, 14 Apr 2014 15:11:42 -0700
Subject: Fix for MAINT-5707 bad breakpad behavior with teleport links

---
 indra/llcommon/llapp.cpp           | 70 ++++++++++++++++++++++----------------
 indra/llcommon/llapp.h             |  2 +-
 indra/newview/llappviewer.cpp      |  2 +-
 indra/newview/llappviewer.h        |  1 +
 indra/newview/llappviewerwin32.cpp |  2 ++
 5 files changed, 46 insertions(+), 31 deletions(-)

(limited to 'indra')

diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp
index 5c8fff051f..63a38f2884 100755
--- a/indra/llcommon/llapp.cpp
+++ b/indra/llcommon/llapp.cpp
@@ -320,7 +320,7 @@ void EnableCrashingOnCrashes()
 }
 #endif
 
-void LLApp::setupErrorHandling()
+void LLApp::setupErrorHandling(bool second_instance)
 {
 	// Error handling is done by starting up an error handling thread, which just sleeps and
 	// occasionally checks to see if the app is in an error state, and sees if it needs to be run.
@@ -337,40 +337,52 @@ void LLApp::setupErrorHandling()
 	// Install the Google Breakpad crash handler for Windows
 	if(mExceptionHandler == 0)
 	{
-		llwarns << "adding breakpad exception handler" << llendl;
+		if ( second_instance )  //BUG-5707 Firing teleport from a web browser causes second 
+		{
+			mExceptionHandler = new google_breakpad::ExceptionHandler(
+															L"C:\\Temp\\",		
+															0,		//No filter
+															windows_post_minidump_callback,
+															0,
+															google_breakpad::ExceptionHandler::HANDLER_ALL);  //No custom client info.
+		}
+		else
+		{
+			llwarns << "adding breakpad exception handler" << llendl;
 
-		std::wstring wpipe_name;
-		wpipe_name =  mCrashReportPipeStr + wstringize(getPid());
+			std::wstring wpipe_name;
+			wpipe_name =  mCrashReportPipeStr + wstringize(getPid());
 
-		const std::wstring wdump_path(wstringize(mDumpPath));
+			const std::wstring wdump_path(wstringize(mDumpPath));
 
-		int retries = 30;
-		for (; retries > 0; --retries)
-		{
-			if (mExceptionHandler != 0) delete mExceptionHandler;
-
-			mExceptionHandler = new google_breakpad::ExceptionHandler(
-														wdump_path,		
-														NULL,		//No filter
-														windows_post_minidump_callback,
-														0,
-														google_breakpad::ExceptionHandler::HANDLER_ALL,
-														MiniDumpNormal, //Generate a 'normal' minidump.
-														wpipe_name.c_str(),
-														NULL);  //No custom client info.
-			if (mExceptionHandler->IsOutOfProcess())
+			int retries = 30;
+			for (; retries > 0; --retries)
 			{
-				LL_INFOS("CRASHREPORT") << "Successfully attached to Out of Process exception handler." << LL_ENDL;
-				break;
-			}
-			else
-			{
-				LL_WARNS("CRASHREPORT") << "Unable to attach to Out of Process exception handler.  " << retries << " retries remaining." << LL_ENDL; 
-				::Sleep(100);  //Wait a tick and try again.
+				if (mExceptionHandler != 0) delete mExceptionHandler;
+
+				mExceptionHandler = new google_breakpad::ExceptionHandler(
+															wdump_path,		
+															NULL,		//No filter
+															windows_post_minidump_callback,
+															0,
+															google_breakpad::ExceptionHandler::HANDLER_ALL,
+															MiniDumpNormal, //Generate a 'normal' minidump.
+															wpipe_name.c_str(),
+															NULL);  //No custom client info.
+				if (mExceptionHandler->IsOutOfProcess())
+				{
+					LL_INFOS("CRASHREPORT") << "Successfully attached to Out of Process exception handler." << LL_ENDL;
+					break;
+				}
+				else
+				{
+					LL_WARNS("CRASHREPORT") << "Unable to attach to Out of Process exception handler.  " << retries << " retries remaining." << LL_ENDL; 
+					::Sleep(100);  //Wait a tick and try again.
+				}
 			}
-		}
 
-		if (retries == 0) LL_WARNS("CRASHREPORT") << "Unable to attach to Out of Process exception handler." << LL_ENDL;
+			if (retries == 0) LL_WARNS("CRASHREPORT") << "Unable to attach to Out of Process exception handler." << LL_ENDL;
+		}
 
 		if (mExceptionHandler)
 		{
diff --git a/indra/llcommon/llapp.h b/indra/llcommon/llapp.h
index 828965b1fa..3f7bf2ca47 100755
--- a/indra/llcommon/llapp.h
+++ b/indra/llcommon/llapp.h
@@ -214,7 +214,7 @@ public:
 	 * DO NOT call this method if your application has specialized
 	 * error handling code.
 	 */
-	void setupErrorHandling();
+	void setupErrorHandling(bool mSecondInstance=false);
 
 	void setErrorHandler(LLAppErrorHandler handler);
 	static void runErrorHandler(); // run shortly after we detect an error, ran in the relatively robust context of the LLErrorThread - preferred.
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 63d31824e4..413a0abf47 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -740,7 +740,7 @@ public:
 
 bool LLAppViewer::init()
 {	
-	setupErrorHandling();
+	setupErrorHandling(mSecondInstance);
 
 	//
 	// Start of the application
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index cbaa7bc4c2..25b5c90bb0 100755
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -80,6 +80,7 @@ public:
 
     bool quitRequested() { return mQuitRequested; }
     bool logoutRequestSent() { return mLogoutRequestSent; }
+	bool isSecondInstance() { return mSecondInstance; }
 
 	void writeDebugInfo(bool isStatic=true);
 
diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp
index d9a0eb25e4..5585bd914c 100644
--- a/indra/newview/llappviewerwin32.cpp
+++ b/indra/newview/llappviewerwin32.cpp
@@ -674,6 +674,8 @@ bool LLAppViewerWin32::restoreErrorTrap()
 
 void LLAppViewerWin32::initCrashReporting(bool reportFreeze)
 {
+	if (isSecondInstance()) return; //BUG-5707 do not start another crash reporter for second instance.
+
 	const char* logger_name = "win_crash_logger.exe";
 	std::string exe_path = gDirUtilp->getExecutableDir();
 	exe_path += gDirUtilp->getDirDelimiter();
-- 
cgit v1.2.3