From 0a0ae2dd3f3d1f27b5fe13d02118866aa7cbb7d7 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 13 Sep 2011 12:45:28 -0500
Subject: STORM-1562 Potential fix for crash in LLCurl::run -- don't run
 curl_multi_perform from multiple threads simultaneously.

---
 indra/llmessage/llcurl.cpp | 6 +++++-
 indra/llmessage/llcurl.h   | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

(limited to 'indra/llmessage')

diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index 14e169c6b1..280a8942a8 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -222,7 +222,7 @@ namespace boost
 std::set<CURL*> LLCurl::Easy::sFreeHandles;
 std::set<CURL*> LLCurl::Easy::sActiveHandles;
 LLMutex* LLCurl::Easy::sHandleMutex = NULL;
-
+LLMutex* LLCurl::Easy::sMultiMutex = NULL;
 
 //static
 CURL* LLCurl::Easy::allocEasyHandle()
@@ -606,6 +606,7 @@ void LLCurl::Multi::run()
 		mPerformState = PERFORM_STATE_PERFORMING;
 		if (!mQuitting)
 		{
+			LLMutexLock lock(LLCurl::Easy::sMultiMutex);
 			doPerform();
 		}
 	}
@@ -1179,6 +1180,7 @@ void LLCurl::initClass(bool multi_threaded)
 	check_curl_code(code);
 	
 	Easy::sHandleMutex = new LLMutex();
+	Easy::sMultiMutex = new LLMutex();
 
 #if SAFE_SSL
 	S32 mutex_count = CRYPTO_num_locks();
@@ -1200,6 +1202,8 @@ void LLCurl::cleanupClass()
 
 	delete Easy::sHandleMutex;
 	Easy::sHandleMutex = NULL;
+	delete Easy::sMultiMutex;
+	Easy::sMultiMutex = NULL;
 
 	for (std::set<CURL*>::iterator iter = Easy::sFreeHandles.begin(); iter != Easy::sFreeHandles.end(); ++iter)
 	{
diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h
index 213b281e72..a876a1562e 100644
--- a/indra/llmessage/llcurl.h
+++ b/indra/llmessage/llcurl.h
@@ -251,6 +251,7 @@ private:
 	static std::set<CURL*> sFreeHandles;
 	static std::set<CURL*> sActiveHandles;
 	static LLMutex* sHandleMutex;
+	static LLMutex* sMultiMutex;
 };
 
 class LLCurl::Multi : public LLThread
-- 
cgit v1.2.3


From 758b936deaa0e6ea397c49afa5024315415eeb93 Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Wed, 14 Sep 2011 13:24:31 -0400
Subject: Trying to fix Mac build issue

---
 indra/llmessage/llcurl.h | 1 +
 1 file changed, 1 insertion(+)
 mode change 100644 => 100755 indra/llmessage/llcurl.h

(limited to 'indra/llmessage')

diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h
old mode 100644
new mode 100755
index a876a1562e..87de202717
--- a/indra/llmessage/llcurl.h
+++ b/indra/llmessage/llcurl.h
@@ -232,6 +232,7 @@ public:
 
 private:
 	friend class LLCurl;
+	friend class LLCurl::Multi;
 
 	CURL*				mCurlEasyHandle;
 	struct curl_slist*	mHeaders;
-- 
cgit v1.2.3