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:
@@ -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 << "].");
|
||||
|
||||
@@ -75,6 +75,7 @@ class MultiHandle : public CurlMultiHandle
|
||||
typedef std::set<AICurlEasyRequest, AICurlEasyRequestCompare> addedEasyRequests_type;
|
||||
addedEasyRequests_type mAddedEasyRequests; // All easy requests currently added to the multi handle.
|
||||
long mTimeout; // The last timeout in ms as set by the callback CURLMOPT_TIMERFUNCTION.
|
||||
static LLAtomicU32 sTotalAdded; // The (sum of the) size of mAddedEasyRequests (of every MultiHandle, but there is only one).
|
||||
|
||||
private:
|
||||
// Store result and trigger events for easy request.
|
||||
@@ -96,6 +97,9 @@ class MultiHandle : public CurlMultiHandle
|
||||
// Called from the main loop every time select() timed out.
|
||||
void handle_stalls(void);
|
||||
|
||||
// Return the total number of added curl requests.
|
||||
static U32 total_added_size(void) { return sTotalAdded; }
|
||||
|
||||
public:
|
||||
//-----------------------------------------------------------------------------
|
||||
// Curl socket administration:
|
||||
|
||||
Reference in New Issue
Block a user