summaryrefslogtreecommitdiff
path: root/indra/llmessage
diff options
context:
space:
mode:
authorprep <prep@lindenlab.com>2012-11-28 16:36:34 -0500
committerprep <prep@lindenlab.com>2012-11-28 16:36:34 -0500
commite0432f98ee515f9777604aa784d28b63d2abfe40 (patch)
tree398fcae43d9904bde2112a7085c7ef7c1a926100 /indra/llmessage
parentbf87920fc91e2ca2b8d9f6f2656ad632c3005164 (diff)
parentf5a47417fde70f78b99744386c6da0bcf78e60d5 (diff)
SH-3563. Pull and merge from viewer-development. Modest code changes to fix alignment issue in llAppearance.
Diffstat (limited to 'indra/llmessage')
-rw-r--r--indra/llmessage/llavatarnamecache.cpp58
-rw-r--r--indra/llmessage/llavatarnamecache.h4
-rw-r--r--indra/llmessage/llcurl.cpp85
-rw-r--r--indra/llmessage/llcurl.h15
-rw-r--r--indra/llmessage/tests/llcurl_stub.cpp17
-rw-r--r--indra/llmessage/tests/llhttpclient_test.cpp5
6 files changed, 87 insertions, 97 deletions
diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp
index 32d9d8bfc3..700525e1fa 100644
--- a/indra/llmessage/llavatarnamecache.cpp
+++ b/indra/llmessage/llavatarnamecache.cpp
@@ -334,8 +334,9 @@ void LLAvatarNameCache::requestNamesViaCapability()
// http://pdp60.lindenlab.com:8000/agents/?ids=3941037e-78ab-45f0-b421-bd6e77c1804d&ids=0012809d-7d2d-4c24-9609-af1230a37715&ids=0019aaba-24af-4f0a-aa72-6457953cf7f0
//
// Apache can handle URLs of 4096 chars, but let's be conservative
- const U32 NAME_URL_MAX = 4096;
- const U32 NAME_URL_SEND_THRESHOLD = 3000;
+ static const U32 NAME_URL_MAX = 4096;
+ static const U32 NAME_URL_SEND_THRESHOLD = 3500;
+
std::string url;
url.reserve(NAME_URL_MAX);
@@ -343,10 +344,12 @@ void LLAvatarNameCache::requestNamesViaCapability()
agent_ids.reserve(128);
U32 ids = 0;
- ask_queue_t::const_iterator it = sAskQueue.begin();
- for ( ; it != sAskQueue.end(); ++it)
+ ask_queue_t::const_iterator it;
+ while(!sAskQueue.empty())
{
+ it = sAskQueue.begin();
const LLUUID& agent_id = *it;
+ sAskQueue.erase(it);
if (url.empty())
{
@@ -369,27 +372,17 @@ void LLAvatarNameCache::requestNamesViaCapability()
if (url.size() > NAME_URL_SEND_THRESHOLD)
{
- LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaCapability first "
- << ids << " ids"
- << LL_ENDL;
- LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids));
- url.clear();
- agent_ids.clear();
+ break;
}
}
if (!url.empty())
{
- LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaCapability all "
+ LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaCapability requested "
<< ids << " ids"
<< LL_ENDL;
LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids));
- url.clear();
- agent_ids.clear();
}
-
- // We've moved all asks to the pending request queue
- sAskQueue.clear();
}
void LLAvatarNameCache::legacyNameCallback(const LLUUID& agent_id,
@@ -416,12 +409,15 @@ void LLAvatarNameCache::legacyNameCallback(const LLUUID& agent_id,
void LLAvatarNameCache::requestNamesViaLegacy()
{
+ static const S32 MAX_REQUESTS = 100;
F64 now = LLFrameTimer::getTotalSeconds();
std::string full_name;
- ask_queue_t::const_iterator it = sAskQueue.begin();
- for (; it != sAskQueue.end(); ++it)
+ ask_queue_t::const_iterator it;
+ for (S32 requests = 0; !sAskQueue.empty() && requests < MAX_REQUESTS; ++requests)
{
+ it = sAskQueue.begin();
const LLUUID& agent_id = *it;
+ sAskQueue.erase(it);
// Mark as pending first, just in case the callback is immediately
// invoked below. This should never happen in practice.
@@ -433,10 +429,6 @@ void LLAvatarNameCache::requestNamesViaLegacy()
boost::bind(&LLAvatarNameCache::legacyNameCallback,
_1, _2, _3));
}
-
- // We've either answered immediately or moved all asks to the
- // pending queue
- sAskQueue.clear();
}
void LLAvatarNameCache::initClass(bool running)
@@ -513,11 +505,11 @@ void LLAvatarNameCache::idle()
// *TODO: Possibly re-enabled this based on People API load measurements
// 100 ms is the threshold for "user speed" operations, so we can
// stall for about that long to batch up requests.
- //const F32 SECS_BETWEEN_REQUESTS = 0.1f;
- //if (!sRequestTimer.checkExpirationAndReset(SECS_BETWEEN_REQUESTS))
- //{
- // return;
- //}
+ const F32 SECS_BETWEEN_REQUESTS = 0.1f;
+ if (!sRequestTimer.hasExpired())
+ {
+ return;
+ }
if (!sAskQueue.empty())
{
@@ -532,6 +524,12 @@ void LLAvatarNameCache::idle()
}
}
+ if (sAskQueue.empty())
+ {
+ // cleared the list, reset the request timer.
+ sRequestTimer.resetWithExpiry(SECS_BETWEEN_REQUESTS);
+ }
+
// erase anything that has not been refreshed for more than MAX_UNREFRESHED_TIME
eraseUnrefreshed();
}
@@ -743,12 +741,6 @@ void LLAvatarNameCache::erase(const LLUUID& agent_id)
sCache.erase(agent_id);
}
-void LLAvatarNameCache::fetch(const LLUUID& agent_id)
-{
- // re-request, even if request is already pending
- sAskQueue.insert(agent_id);
-}
-
void LLAvatarNameCache::insert(const LLUUID& agent_id, const LLAvatarName& av_name)
{
// *TODO: update timestamp if zero?
diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h
index 064942fe53..79f170f7c8 100644
--- a/indra/llmessage/llavatarnamecache.h
+++ b/indra/llmessage/llavatarnamecache.h
@@ -86,10 +86,6 @@ namespace LLAvatarNameCache
/// Provide some fallback for agents that return errors
void handleAgentError(const LLUUID& agent_id);
- // Force a re-fetch of the most recent data, but keep the current
- // data in cache
- void fetch(const LLUUID& agent_id);
-
void insert(const LLUUID& agent_id, const LLAvatarName& av_name);
// Compute name expiration time from HTTP Cache-Control header,
diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index b4ac984d57..8ffa8e4271 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -133,12 +133,12 @@ std::string LLCurl::getVersionString()
//////////////////////////////////////////////////////////////////////////////
LLCurl::Responder::Responder()
- : mReferenceCount(0)
{
}
LLCurl::Responder::~Responder()
{
+ LL_CHECK_MEMORY
}
// virtual
@@ -202,23 +202,6 @@ void LLCurl::Responder::completedHeader(U32 status, const std::string& reason, c
}
-namespace boost
-{
- void intrusive_ptr_add_ref(LLCurl::Responder* p)
- {
- ++p->mReferenceCount;
- }
-
- void intrusive_ptr_release(LLCurl::Responder* p)
- {
- if (p && 0 == --p->mReferenceCount)
- {
- delete p;
- }
- }
-};
-
-
//////////////////////////////////////////////////////////////////////////////
std::set<CURL*> LLCurl::Easy::sFreeHandles;
@@ -267,15 +250,18 @@ void LLCurl::Easy::releaseEasyHandle(CURL* handle)
LLMutexLock lock(sHandleMutexp) ;
if (sActiveHandles.find(handle) != sActiveHandles.end())
{
+ LL_CHECK_MEMORY
sActiveHandles.erase(handle);
-
+ LL_CHECK_MEMORY
if(sFreeHandles.size() < MAX_NUM_FREE_HANDLES)
{
- sFreeHandles.insert(handle);
- }
- else
- {
+ sFreeHandles.insert(handle);
+ LL_CHECK_MEMORY
+ }
+ else
+ {
LLCurl::deleteEasyHandle(handle) ;
+ LL_CHECK_MEMORY
}
}
else
@@ -308,6 +294,8 @@ LLCurl::Easy* LLCurl::Easy::getEasy()
// multi handles cache if they are added to one.
CURLcode result = curl_easy_setopt(easy->mCurlEasyHandle, CURLOPT_DNS_CACHE_TIMEOUT, 0);
check_curl_code(result);
+ result = curl_easy_setopt(easy->mCurlEasyHandle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
+ check_curl_code(result);
++gCurlEasyCount;
return easy;
@@ -318,13 +306,15 @@ LLCurl::Easy::~Easy()
releaseEasyHandle(mCurlEasyHandle);
--gCurlEasyCount;
curl_slist_free_all(mHeaders);
+ LL_CHECK_MEMORY
for_each(mStrings.begin(), mStrings.end(), DeletePointerArray());
-
+ LL_CHECK_MEMORY
if (mResponder && LLCurl::sNotQuitting) //aborted
{
std::string reason("Request timeout, aborted.") ;
mResponder->completedRaw(408, //HTTP_REQUEST_TIME_OUT, timeout, abort
reason, mChannels, mOutput);
+ LL_CHECK_MEMORY
}
mResponder = NULL;
}
@@ -494,7 +484,8 @@ void LLCurl::Easy::prepRequest(const std::string& url,
//setopt(CURLOPT_VERBOSE, 1); // useful for debugging
setopt(CURLOPT_NOSIGNAL, 1);
-
+ setopt(CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
+
// Set the CURL options for either Socks or HTTP proxy
LLProxy::getInstance()->applyProxySettings(this);
@@ -599,35 +590,50 @@ void LLCurl::Multi::cleanup(bool deleted)
llassert_always(deleted || !mValid) ;
LLMutexLock lock(mDeletionMutexp);
-
+
+
// Clean up active
for(easy_active_list_t::iterator iter = mEasyActiveList.begin();
iter != mEasyActiveList.end(); ++iter)
{
Easy* easy = *iter;
+ LL_CHECK_MEMORY
check_curl_multi_code(curl_multi_remove_handle(mCurlMultiHandle, easy->getCurlHandle()));
-
+ LL_CHECK_MEMORY
if(deleted)
{
easy->mResponder = NULL ; //avoid triggering mResponder.
+ LL_CHECK_MEMORY
}
delete easy;
+ LL_CHECK_MEMORY
}
mEasyActiveList.clear();
mEasyActiveMap.clear();
- // Clean up freed
+ LL_CHECK_MEMORY
+
+ // Clean up freed
for_each(mEasyFreeList.begin(), mEasyFreeList.end(), DeletePointer());
mEasyFreeList.clear();
-
+
+ LL_CHECK_MEMORY
+
check_curl_multi_code(LLCurl::deleteMultiHandle(mCurlMultiHandle));
mCurlMultiHandle = NULL ;
+
+ LL_CHECK_MEMORY
delete mMutexp ;
mMutexp = NULL ;
+
+ LL_CHECK_MEMORY
+
delete mEasyMutexp ;
mEasyMutexp = NULL ;
+ LL_CHECK_MEMORY
+
mQueued = 0 ;
mState = STATE_COMPLETED;
@@ -1104,6 +1110,7 @@ bool LLCurlRequest::getByteRange(const std::string& url,
S32 offset, S32 length,
LLCurl::ResponderPtr responder)
{
+ llassert(LLCurl::sNotQuitting);
LLCurl::Easy* easy = allocEasy();
if (!easy)
{
@@ -1131,6 +1138,7 @@ bool LLCurlRequest::post(const std::string& url,
const LLSD& data,
LLCurl::ResponderPtr responder, S32 time_out)
{
+ llassert(LLCurl::sNotQuitting);
LLCurl::Easy* easy = allocEasy();
if (!easy)
{
@@ -1158,6 +1166,7 @@ bool LLCurlRequest::post(const std::string& url,
const std::string& data,
LLCurl::ResponderPtr responder, S32 time_out)
{
+ llassert(LLCurl::sNotQuitting);
LLCurl::Easy* easy = allocEasy();
if (!easy)
{
@@ -1714,29 +1723,42 @@ void LLCurl::cleanupClass()
break ;
}
}
+ LL_CHECK_MEMORY
sCurlThread->shutdown() ;
+ LL_CHECK_MEMORY
delete sCurlThread ;
sCurlThread = NULL ;
+ LL_CHECK_MEMORY
#if SAFE_SSL
CRYPTO_set_locking_callback(NULL);
for_each(sSSLMutex.begin(), sSSLMutex.end(), DeletePointer());
#endif
+
+ LL_CHECK_MEMORY
for (std::set<CURL*>::iterator iter = Easy::sFreeHandles.begin(); iter != Easy::sFreeHandles.end(); ++iter)
{
CURL* curl = *iter;
LLCurl::deleteEasyHandle(curl);
}
+
+ LL_CHECK_MEMORY
Easy::sFreeHandles.clear();
+ LL_CHECK_MEMORY
+
delete Easy::sHandleMutexp ;
Easy::sHandleMutexp = NULL ;
+ LL_CHECK_MEMORY
+
delete sHandleMutexp ;
sHandleMutexp = NULL ;
+ LL_CHECK_MEMORY
+
// removed as per https://jira.secondlife.com/browse/SH-3115
//llassert(Easy::sActiveHandles.empty());
}
@@ -1744,6 +1766,8 @@ void LLCurl::cleanupClass()
//static
CURLM* LLCurl::newMultiHandle()
{
+ llassert(sNotQuitting);
+
LLMutexLock lock(sHandleMutexp) ;
if(sTotalHandles + 1 > sMaxHandles)
@@ -1777,6 +1801,7 @@ CURLMcode LLCurl::deleteMultiHandle(CURLM* handle)
//static
CURL* LLCurl::newEasyHandle()
{
+ llassert(sNotQuitting);
LLMutexLock lock(sHandleMutexp) ;
if(sTotalHandles + 1 > sMaxHandles)
@@ -1801,7 +1826,9 @@ void LLCurl::deleteEasyHandle(CURL* handle)
if(handle)
{
LLMutexLock lock(sHandleMutexp) ;
+ LL_CHECK_MEMORY
curl_easy_cleanup(handle) ;
+ LL_CHECK_MEMORY
sTotalHandles-- ;
}
}
diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h
index 20ebd86c06..7bcf61e233 100644
--- a/indra/llmessage/llcurl.h
+++ b/indra/llmessage/llcurl.h
@@ -44,6 +44,8 @@
#include "llthread.h"
#include "llqueuedthread.h"
#include "llframetimer.h"
+#include "llpointer.h"
+
class LLMutex;
class LLCurlThread;
@@ -67,7 +69,7 @@ public:
F64 mSpeedDownload;
};
- class Responder
+ class Responder : public LLThreadSafeRefCount
{
//LOG_CLASS(Responder);
public:
@@ -126,13 +128,10 @@ public:
return false;
}
- public: /* but not really -- don't touch this */
- U32 mReferenceCount;
-
private:
std::string mURL;
};
- typedef boost::intrusive_ptr<Responder> ResponderPtr;
+ typedef LLPointer<Responder> ResponderPtr;
/**
@@ -378,12 +377,6 @@ private:
void cleanupMulti(LLCurl::Multi* multi) ;
} ;
-namespace boost
-{
- void intrusive_ptr_add_ref(LLCurl::Responder* p);
- void intrusive_ptr_release(LLCurl::Responder* p);
-};
-
class LLCurlRequest
{
diff --git a/indra/llmessage/tests/llcurl_stub.cpp b/indra/llmessage/tests/llcurl_stub.cpp
index d84fe0a49f..9b298d0c04 100644
--- a/indra/llmessage/tests/llcurl_stub.cpp
+++ b/indra/llmessage/tests/llcurl_stub.cpp
@@ -28,7 +28,6 @@
#include "llcurl.h"
LLCurl::Responder::Responder()
- : mReferenceCount(0)
{
}
@@ -77,19 +76,3 @@ void LLCurl::Responder::result(LLSD const&)
{
}
-namespace boost
-{
- void intrusive_ptr_add_ref(LLCurl::Responder* p)
- {
- ++p->mReferenceCount;
- }
-
- void intrusive_ptr_release(LLCurl::Responder* p)
- {
- if(p && 0 == --p->mReferenceCount)
- {
- delete p;
- }
- }
-};
-
diff --git a/indra/llmessage/tests/llhttpclient_test.cpp b/indra/llmessage/tests/llhttpclient_test.cpp
index 4a9db7cd98..50f1df608f 100644
--- a/indra/llmessage/tests/llhttpclient_test.cpp
+++ b/indra/llmessage/tests/llhttpclient_test.cpp
@@ -137,9 +137,9 @@ namespace tut
}
public:
- static boost::intrusive_ptr<Result> build(HTTPClientTestData& client)
+ static Result* build(HTTPClientTestData& client)
{
- return boost::intrusive_ptr<Result>(new Result(client));
+ return new Result(client);
}
~Result()
@@ -206,7 +206,6 @@ namespace tut
void HTTPClientTestObject::test<1>()
{
LLHTTPClient::get(local_server, newResult());
-
runThePump();
ensureStatusOK();
ensure("result object wasn't destroyed", mResultDeleted);