Added MultiHandle::sTotalAdded

This new variable is updated to contain the total number of requests in
MultiHandle::mAddedEasyRequests. It can be a static because MultiHandle
is a singleton (there is only one curl thread) and it has to be an
(atomic) static because we don't want to need to take the lock on
MultiHandle for accessing this variable.
This commit is contained in:
Aleric Inglewood
2013-04-05 20:49:23 +02:00
parent 6c9b136d32
commit db7c378160
2 changed files with 10 additions and 0 deletions

View File

@@ -1581,6 +1581,8 @@ void AICurlThread::run(void)
//-----------------------------------------------------------------------------
// MultiHandle
LLAtomicU32 MultiHandle::sTotalAdded;
MultiHandle::MultiHandle(void) : mTimeout(-1), mReadPollSet(NULL), mWritePollSet(NULL)
{
mReadPollSet = new PollSet;
@@ -1717,6 +1719,8 @@ void MultiHandle::add_easy_request(AICurlEasyRequest const& easy_request)
{ // ... to here.
std::pair<addedEasyRequests_type::iterator, bool> res = mAddedEasyRequests.insert(easy_request);
llassert(res.second); // May not have been added before.
sTotalAdded++;
llassert(sTotalAdded == mAddedEasyRequests.size());
Dout(dc::curl, "MultiHandle::add_easy_request: Added AICurlEasyRequest " << (void*)easy_request.get_ptr().get() <<
"; now processing " << mAddedEasyRequests.size() << " easy handles [running_handles = " << AICurlInterface::Stats::running_handles << "].");
return;
@@ -1769,6 +1773,8 @@ CURLMcode MultiHandle::remove_easy_request(addedEasyRequests_type::iterator cons
ThreadSafeBufferedCurlEasyRequest* lockobj = iter->get_ptr().get();
#endif
mAddedEasyRequests.erase(iter);
--sTotalAdded;
llassert(sTotalAdded == mAddedEasyRequests.size());
#if CWDEBUG
Dout(dc::curl, "MultiHandle::remove_easy_request: Removed AICurlEasyRequest " << (void*)lockobj <<
"; now processing " << mAddedEasyRequests.size() << " easy handles [running_handles = " << AICurlInterface::Stats::running_handles << "].");