From 5562dc36a1555480ffbc4e45342206de003254af Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 21 Dec 2009 12:23:58 -0600
Subject: [PATCH] Fix for OSX hating thread local state (hopefully).

---
 indra/llcommon/llthread.cpp | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp
index df7ea214cc5..0385569a02e 100644
--- a/indra/llcommon/llthread.cpp
+++ b/indra/llcommon/llthread.cpp
@@ -62,7 +62,10 @@
 // 
 //----------------------------------------------------------------------------
 
+#if !LL_DARWIN
 U32 ll_thread_local sThreadID = 0;
+#endif 
+
 U32 LLThread::sIDIter = 0;
 
 //
@@ -75,7 +78,9 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap
 	// Set thread state to running
 	threadp->mStatus = RUNNING;
 
+#if !LL_DARWIN
 	sThreadID = threadp->mID;
+#endif
 
 	// Run the user supplied function
 	threadp->run();
@@ -312,12 +317,16 @@ LLMutex::~LLMutex()
 
 void LLMutex::lock()
 {
+#if LL_DARWIN
+	if (mLockingThread == LLThread::currentID())
+#else
 	if (mLockingThread == sThreadID)
+#endif
 	{ //redundant lock
 		mCount++;
 		return;
 	}
-
+	
 	apr_thread_mutex_lock(mAPRMutexp);
 	
 #if MUTEX_DEBUG
@@ -328,7 +337,11 @@ void LLMutex::lock()
 	mIsLocked[id] = TRUE;
 #endif
 
+#if LL_DARWIN
+	mLockingThread = LLThread::currentID();
+#else
 	mLockingThread = sThreadID;
+#endif
 }
 
 void LLMutex::unlock()
-- 
GitLab