BaoLinden avatar BaoLinden committed fafd857

fix for sh-2738: Texture fetching freezes due to LLcurl

Comments (0)

Files changed (2)

indra/llcommon/llthread.h

 	LLMutexLock(LLMutex* mutex)
 	{
 		mMutex = mutex;
-		mMutex->lock();
+
+		if(mMutex)
+		{
+			mMutex->lock();
+		}
 	}
 	~LLMutexLock()
 	{
-		mMutex->unlock();
+		if(mMutex)
+		{
+			mMutex->unlock();
+		}
 	}
 private:
 	LLMutex* mMutex;

indra/llmessage/llcurl.cpp

 
 void LLCurl::Multi::markDead()
 {
-	if(mDeletionMutexp)
-	{
-		mDeletionMutexp->lock() ;
-	}
-
+	LLMutexLock lock(mDeletionMutexp) ;
+	
 	mDead = TRUE ;
-
-	if(mDeletionMutexp)
-	{
-		mDeletionMutexp->unlock() ;
-	}
 }
 
 void LLCurl::Multi::setState(LLCurl::Multi::ePerformState state)
 {
-	lock() ;
+	LLMutexLock lock(mMutexp) ;
+
 	mState = state ;
 	if(mState == STATE_READY)
 	{
 		LLCurl::getCurlThread()->setPriority(mHandle, LLQueuedThread::PRIORITY_NORMAL) ;
 	}
-	unlock() ;
 }
 
 LLCurl::Multi::ePerformState LLCurl::Multi::getState()
 {
 	ePerformState state ;
 
-	lock() ;
-	state = mState ;
-	unlock() ;
+	{
+		LLMutexLock lock(mMutexp) ;
+		state = mState ;
+	}
 
 	return state ;
 }
 
 	bool completed ;
 
-	lock() ;
-	completed = (STATE_COMPLETED == mState) ;
-	if(!completed)
 	{
-		LLCurl::getCurlThread()->setPriority(mHandle, LLQueuedThread::PRIORITY_URGENT) ;
+		LLMutexLock lock(mMutexp) ;
+
+		completed = (STATE_COMPLETED == mState) ;
+		if(!completed)
+		{
+			LLCurl::getCurlThread()->setPriority(mHandle, LLQueuedThread::PRIORITY_URGENT) ;
+		}
 	}
-	unlock() ;
 
 	return completed;
 }
 //return true if dead
 bool LLCurl::Multi::doPerform()
 {
-	if(mDeletionMutexp)
-	{
-		mDeletionMutexp->lock() ;
-	}
+	LLMutexLock lock(mDeletionMutexp) ;
+	
 	bool dead = mDead ;
 
 	if(mDead)
 				call_count < MULTI_PERFORM_CALL_REPEAT;
 				call_count++)
 		{
+			LLMutexLock lock(mMutexp) ;
+
 			CURLMcode code = curl_multi_perform(mCurlMultiHandle, &q);
 			if (CURLM_CALL_MULTI_PERFORM != code || q == 0)
 			{
 		setState(STATE_COMPLETED) ;
 	}
 
-	if(mDeletionMutexp)
-	{
-		mDeletionMutexp->unlock() ;
-	}
-
 	return dead ;
 }
 
 
 bool LLCurl::Multi::addEasy(Easy* easy)
 {
+	LLMutexLock lock(mMutexp) ;
+
 	CURLMcode mcode = curl_multi_add_handle(mCurlMultiHandle, easy->getCurlHandle());
 	check_curl_multi_code(mcode);
 	//if (mcode != CURLM_OK)
 
 void LLCurl::Multi::easyFree(Easy* easy)
 {
+	LLMutexLock lock(mMutexp) ;
+
 	mEasyActiveList.erase(easy);
 	mEasyActiveMap.erase(easy->getCurlHandle());
 	if (mEasyFreeList.size() < EASY_HANDLE_POOL_SIZE)
 
 void LLCurl::Multi::removeEasy(Easy* easy)
 {
+	LLMutexLock lock(mMutexp) ;
+
 	check_curl_multi_code(curl_multi_remove_handle(mCurlMultiHandle, easy->getCurlHandle()));
 	easyFree(easy);
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.