Commits

Monty Brandenberg committed 17a1fea

SH-3325 texture load slow on some machines
This doesn't really address 3325 directly but it is the result of research
done while hunting it down. First, this is a thread safety improvement for
canceled requests that have gone into resource wait state. I don't think
we've seen a failure there but there was a window. It also cleans the
resource wait queue earlier which lets us do less work and get requests
more quickly into llcorehttp by bypassing the resource wait state. With
this, I finally feel comfortable about rundown of requests.

Comments (0)

Files changed (2)

indra/newview/lltexturefetch.cpp

 
 	if (WAIT_HTTP_RESOURCE2 == mState)
 	{
-		// Don't delete the worker out from under the
-		// releaseHttpWaiters() method.  Keep the pointers
-		// valid, clean up after transition.
-		delete_ok = false;
+		if (mFetcher->isHttpWaiter(mID))
+		{
+			// Don't delete the worker out from under the releaseHttpWaiters()
+			// method.  Keep the pointers valid, clean up after that method
+			// has recognized the cancelation and removed the UUID from the
+			// waiter list.
+			delete_ok = false;
+		}
 	}
 	
 	// Allow any pending reads or writes to complete
 		unlockQueue();													// -Mfq
 
 		llassert_always(erased_1 > 0) ;
-
 		removeFromNetworkQueue(worker, cancel);
 		llassert_always(!(worker->getFlags(LLWorkerClass::WCF_DELETE_REQUESTED))) ;
 
 	mNetworkQueueMutex.unlock();										// -Mfnq
 }
 
+// Threads:  T*
+bool LLTextureFetch::isHttpWaiter(const LLUUID & tid)
+{
+	mNetworkQueueMutex.lock();											// +Mfnq
+	wait_http_res_queue_t::iterator iter(mHttpWaitResource.find(tid));
+	const bool ret(mHttpWaitResource.end() != iter);
+	mNetworkQueueMutex.unlock();										// -Mfnq
+	return ret;
+}
+
 // Release as many requests as permitted from the WAIT_HTTP_RESOURCE2
 // state to the SEND_HTTP_REQ state based on their current priority.
 //
 		{
 			tids2.push_back(worker);
 		}
+		else
+		{
+			// If worker isn't found, this should be due to a request
+			// for deletion.  We signal our recognition that this
+			// uuid shouldn't be used for resource waiting anymore by
+			// erasing it from the resource waiter list.  That allows
+			// deleteOK to do final deletion on the worker.
+			removeHttpWaiter(* iter);
+		}
 	}
 	tids.clear();
 
 		worker->lockWorkMutex();										// +Mw
 		if (LLTextureFetchWorker::WAIT_HTTP_RESOURCE2 != worker->mState)
 		{
-			// Not in expected state, try the next one
+			// Not in expected state, remove it, try the next one
 			worker->unlockWorkMutex();									// -Mw
+			LL_WARNS("Texture") << "Resource-waited texture " << worker->mID
+								<< " in unexpected state:  " << worker->mState
+								<< ".  Removing from wait list."
+								<< LL_ENDL;
+			removeHttpWaiter(worker->mID);
 			continue;
 		}
 

indra/newview/lltexturefetch.h

     // Threads:  T*
 	void removeHttpWaiter(const LLUUID & tid);
 
+    // Threads:  T*
+	bool isHttpWaiter(const LLUUID & tid);
+
 	// If there are slots, release one or more LLTextureFetchWorker
 	// requests from resource wait state (WAIT_HTTP_RESOURCE) to
 	// active (SEND_HTTP_REQ).