From 6c3375356e7366f4384d9233a43d2c58a01e7241 Mon Sep 17 00:00:00 2001
From: Monty Brandenberg <monty@lindenlab.com>
Date: Fri, 21 Dec 2012 22:21:58 +0000
Subject: SH-3331 Fix incorrect overrun message when sending body with HTTP
 request.  During readcallback, would generate an overrun-type message about
 reading position beyond end-of-data.  Mistake was is messaging when state is
 exactly at end of data (which is expected) versus an overrun.  Both result in
 declaring end-of-data to libcurl.  Also changed some of the status logging
 for the metrics payload to be less chatty on success, more informative on
 error.

---
 indra/llcorehttp/_httpoprequest.cpp | 9 +++++++--
 indra/newview/lltexturefetch.cpp    | 9 +++++----
 2 files changed, 12 insertions(+), 6 deletions(-)

(limited to 'indra')

diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp
index 7db19b1841..51a8eaf998 100644
--- a/indra/llcorehttp/_httpoprequest.cpp
+++ b/indra/llcorehttp/_httpoprequest.cpp
@@ -580,8 +580,13 @@ size_t HttpOpRequest::readCallback(void * data, size_t size, size_t nmemb, void
 	const size_t body_size(op->mReqBody->size());
 	if (body_size <= op->mCurlBodyPos)
 	{
-		LL_WARNS("HttpCore") << "Request body position beyond body size.  Aborting request."
-							 << LL_ENDL;
+		if (body_size < op->mCurlBodyPos)
+		{
+			// Warn but continue if the read position moves beyond end-of-body
+			// for some reason.
+			LL_WARNS("HttpCore") << "Request body position beyond body size.  Truncating request body."
+								 << LL_ENDL;
+		}
 		return 0;
 	}
 
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index a2854dd6d8..8af403c1c6 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -3678,13 +3678,14 @@ public:
 
 		if (status)
 		{
-			LL_WARNS("Texture") << "Successfully delivered asset metrics to grid."
-								<< LL_ENDL;
+			LL_DEBUGS("Texture") << "Successfully delivered asset metrics to grid."
+								 << LL_ENDL;
 		}
 		else
 		{
-			LL_WARNS("Texture") << "Error delivering asset metrics to grid.  Reason:  "
-								<< status.toString() << LL_ENDL;
+			LL_WARNS("Texture") << "Error delivering asset metrics to grid.  Status:  "
+								<< status.toHex()
+								<< ", Reason:  " << status.toString() << LL_ENDL;
 		}
 	}
 }; // end class AssetReportHandler
-- 
cgit v1.2.3


From 11e506f2eb979a5ddfc3ca6f9c626771ab012a78 Mon Sep 17 00:00:00 2001
From: Monty Brandenberg <monty@lindenlab.com>
Date: Fri, 21 Dec 2012 22:24:34 +0000
Subject: SH-3357 Texture fetch debugger not running correctly under drano-
 http phase 1 Some missing counter initialization kept the debugger from
 entering the startup state giving the appearance of a do- nothing floater. 
 Also found some unbound recursion that might need looking at in the future. 
 (There's a comment.)

---
 indra/newview/llfloatertexturefetchdebugger.cpp |  2 +-
 indra/newview/lltexturefetch.cpp                | 45 +++++++++++++------------
 indra/newview/lltexturefetch.h                  |  2 --
 3 files changed, 24 insertions(+), 25 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llfloatertexturefetchdebugger.cpp b/indra/newview/llfloatertexturefetchdebugger.cpp
index 9157389187..9a23d99802 100644
--- a/indra/newview/llfloatertexturefetchdebugger.cpp
+++ b/indra/newview/llfloatertexturefetchdebugger.cpp
@@ -4,7 +4,7 @@
  *
  * $LicenseInfo:firstyear=2007&license=viewerlgpl$
  * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * Copyright (C) 2012, Linden Research, Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 8af403c1c6..cd4fa78cab 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -3885,11 +3885,15 @@ private:
 
 
 LLTextureFetchDebugger::LLTextureFetchDebugger(LLTextureFetch* fetcher, LLTextureCache* cache, LLImageDecodeThread* imagedecodethread) :
+	LLCore::HttpHandler(),
 	mFetcher(fetcher),
 	mTextureCache(cache),
 	mImageDecodeThread(imagedecodethread),
 	mHttpHeaders(NULL),
-	mHttpPolicyClass(fetcher->getPolicyClass())
+	mHttpPolicyClass(fetcher->getPolicyClass()),
+	mNbCurlCompleted(0),
+	mTempIndex(0),
+	mHistoryListIndex(0)
 {
 	init();
 }
@@ -3915,6 +3919,7 @@ void LLTextureFetchDebugger::init()
 	mDecodingTime = -1.f;
 	mHTTPTime = -1.f;
 	mGLCreationTime = -1.f;
+
 	mTotalFetchingTime = 0.f;
 	mRefetchVisCacheTime = -1.f;
 	mRefetchVisHTTPTime = -1.f;
@@ -3941,6 +3946,9 @@ void LLTextureFetchDebugger::init()
 	mFreezeHistory = FALSE;
 	mStopDebug = FALSE;
 	mClearHistory = FALSE;
+	mRefetchNonVis = FALSE;
+	
+	mNbCurlRequests = 0;
 
 	if (! mHttpHeaders)
 	{
@@ -4014,7 +4022,8 @@ bool LLTextureFetchDebugger::processStartDebug(F32 max_time)
 		S32 pending = 0;
 		pending += LLAppViewer::getTextureCache()->update(1); 
 		pending += LLAppViewer::getImageDecodeThread()->update(1); 
-		pending += LLAppViewer::getTextureFetch()->update(1); 
+		// pending += LLAppViewer::getTextureFetch()->update(1);  // This causes infinite recursion in some cases
+		pending += mNbCurlRequests;
 		if(!pending)
 		{
 			break;
@@ -4304,7 +4313,6 @@ void LLTextureFetchDebugger::debugHTTP()
 	{
 		mFetchingHistory[i].mCurlState = FetchEntry::CURL_NOT_DONE;
 		mFetchingHistory[i].mCurlReceivedSize = 0;
-		mFetchingHistory[i].mHTTPFailCount = 0;
 		mFetchingHistory[i].mFormattedImage = NULL;
 	}
 	mNbCurlRequests = 0;
@@ -4328,8 +4336,6 @@ S32 LLTextureFetchDebugger::fillCurlQueue()
 	S32 size = mFetchingHistory.size();
 	for (S32 i = 0 ; i < size ; i++)
 	{		
-		mNbCurlRequests++;
-
 		if (mFetchingHistory[i].mCurlState != FetchEntry::CURL_NOT_DONE)
 		{
 			continue;
@@ -4355,15 +4361,22 @@ S32 LLTextureFetchDebugger::fillCurlQueue()
 			mFetchingHistory[i].mHttpHandle = handle;
 			mFetchingHistory[i].mCurlState = FetchEntry::CURL_IN_PROGRESS;
 			mNbCurlRequests++;
-			// Hack
-			if (mNbCurlRequests == HTTP_REQUESTS_IN_QUEUE_HIGH_WATER)	// emulate normal pipeline
+			if (mNbCurlRequests >= HTTP_REQUESTS_IN_QUEUE_HIGH_WATER)	// emulate normal pipeline
 			{
 				break;
 			}
 		}
 		else 
 		{
-			break;
+			// Failed to queue request, log it and mark it done.
+			LLCore::HttpStatus status(mFetcher->getHttpRequest().getStatus());
+
+			LL_WARNS("Texture") << "Couldn't issue HTTP request in debugger for texture "
+								<< mFetchingHistory[i].mID
+								<< ", status: " << status.toHex()
+								<< " reason:  " << status.toString()
+								<< LL_ENDL;
+			mFetchingHistory[i].mCurlState = FetchEntry::CURL_DONE;
 		}
 	}
 	//llinfos << "Fetch Debugger : Having " << mNbCurlRequests << " requests through the curl thread." << llendl;
@@ -4717,14 +4730,13 @@ void LLTextureFetchDebugger::callbackHTTP(FetchEntry & fetch, LLCore::HttpRespon
 	
 	LLCore::HttpStatus status(response->getStatus());
 	mNbCurlRequests--;
+	mNbCurlCompleted++;
+	fetch.mCurlState = FetchEntry::CURL_DONE;
 	if (status)
 	{
 		const bool partial(par_status == status);
 		LLCore::BufferArray * ba(response->getBody());	// *Not* holding reference to body
 		
-		fetch.mCurlState = FetchEntry::CURL_DONE;
-		mNbCurlCompleted++;
-
 		S32 data_size = ba ? ba->size() : 0;
 		fetch.mCurlReceivedSize += data_size;
 		//llinfos << "Fetch Debugger : got results for " << fetch.mID << ", data_size = " << data_size << ", received = " << fetch.mCurlReceivedSize << ", requested = " << fetch.mRequestedSize << ", partial = " << partial << llendl;
@@ -4756,17 +4768,6 @@ void LLTextureFetchDebugger::callbackHTTP(FetchEntry & fetch, LLCore::HttpRespon
 		llinfos << "Fetch Debugger : CURL GET FAILED,  ID = " << fetch.mID
 				<< ", status: " << status.toHex()
 				<< " reason:  " << status.toString() << llendl;
-		fetch.mHTTPFailCount++;
-		if(fetch.mHTTPFailCount < 5)
-		{
-			// Fetch will have to be redone
-			fetch.mCurlState = FetchEntry::CURL_NOT_DONE;
-		}
-		else //skip
-		{
-			fetch.mCurlState = FetchEntry::CURL_DONE;
-			mNbCurlCompleted++;
-		}
 	}
 }
 
diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h
index 3a99432b48..2377a54f92 100644
--- a/indra/newview/lltexturefetch.h
+++ b/indra/newview/lltexturefetch.h
@@ -449,7 +449,6 @@ private:
 		LLPointer<LLImageRaw> mRawImage;
 		e_curl_state mCurlState;
 		S32 mCurlReceivedSize;
-		S32 mHTTPFailCount;
 		LLCore::HttpHandle mHttpHandle;
 
 		FetchEntry() :
@@ -465,7 +464,6 @@ private:
 			mFetchedSize(f_size),
 			mDecodedSize(d_size),
 			mNeedsAux(false),
-			mHTTPFailCount(0),
 			mHttpHandle(LLCORE_HTTP_HANDLE_INVALID)
 			{}
 	};
-- 
cgit v1.2.3