Added progress meter in HTTP debug console.

This commit is contained in:
Aleric Inglewood
2013-07-02 02:07:07 +02:00
parent 0353498b9c
commit 59716ba86b
5 changed files with 58 additions and 15 deletions

View File

@@ -977,7 +977,6 @@ void CurlEasyRequest::resetState(void)
mTimeoutPolicy = NULL;
mTimeout = NULL;
mHandleEventsTarget = NULL;
mResult = CURLE_FAILED_INIT;
applyDefaultOptions();
}

View File

@@ -339,7 +339,7 @@ void AIPerService::added_to_multi_handle(AICapabilityType capability_type)
++mTotalAdded;
}
void AIPerService::removed_from_multi_handle(AICapabilityType capability_type, bool downloaded_something)
void AIPerService::removed_from_multi_handle(AICapabilityType capability_type, bool downloaded_something, bool success)
{
CapabilityType& ct(mCapabilityType[capability_type]);
llassert(mTotalAdded > 0 && ct.mAdded > 0);
@@ -354,6 +354,10 @@ void AIPerService::removed_from_multi_handle(AICapabilityType capability_type, b
{
mark_unused(capability_type);
}
if (success)
{
ct.mFlags |= ctf_success;
}
}
// Returns true if the request was queued.

View File

@@ -134,6 +134,11 @@ class AIPerService {
static U16 const ctf_empty = 1;
static U16 const ctf_full = 2;
static U16 const ctf_starvation = 4;
// Flags used by the HTTP debug console.
static U16 const ctf_success = 8;
static U16 const ctf_progress_mask = 0x70;
static U16 const ctf_progress_shift = 4;
static U16 const ctf_grey = 0x80;
struct CapabilityType {
typedef std::deque<AICurlPrivate::BufferedCurlEasyRequestPtr> queued_request_type;
@@ -145,6 +150,7 @@ class AIPerService {
U16 mFlags; // ctf_empty: Set to true when the queue becomes precisely empty.
// ctf_full : Set to true when the queue is popped and then still isn't empty;
// ctf_starvation: Set to true when the queue was about to be popped but was already empty.
// ctf_success: Set to true when a curl request finished successfully.
U32 mDownloading; // The number of active easy handles with this service for which data was received.
U16 mMaxPipelinedRequests; // The maximum number of accepted requests for this service and (approved) capability type, that didn't finish yet.
U16 mConcurrentConnections; // The maximum number of allowed concurrent connections to the service of this capability type.
@@ -259,7 +265,7 @@ class AIPerService {
void added_to_command_queue(AICapabilityType capability_type) { ++mCapabilityType[capability_type].mQueuedCommands; mark_inuse(capability_type); }
void removed_from_command_queue(AICapabilityType capability_type) { --mCapabilityType[capability_type].mQueuedCommands; llassert(mCapabilityType[capability_type].mQueuedCommands >= 0); }
void added_to_multi_handle(AICapabilityType capability_type); // Called when an easy handle for this service has been added to the multi handle.
void removed_from_multi_handle(AICapabilityType capability_type, bool downloaded_something); // Called when an easy handle for this service is removed again from the multi handle.
void removed_from_multi_handle(AICapabilityType capability_type, bool downloaded_something, bool success); // Called when an easy handle for this service is removed again from the multi handle.
void download_started(AICapabilityType capability_type) { ++mCapabilityType[capability_type].mDownloading; }
bool throttled(AICapabilityType capability_type) const; // Returns true if the maximum number of allowed requests for this service/capability type have been added to the multi handle.
bool nothing_added(AICapabilityType capability_type) const { return mCapabilityType[capability_type].mAdded == 0; }

View File

@@ -1647,7 +1647,7 @@ MultiHandle::~MultiHandle()
// Curl demands that all handles are removed from the multi session handle before calling curl_multi_cleanup.
for(addedEasyRequests_type::iterator iter = mAddedEasyRequests.begin(); iter != mAddedEasyRequests.end(); iter = mAddedEasyRequests.begin())
{
finish_easy_request(*iter, CURLE_OK); // Error code is not used anyway.
finish_easy_request(*iter, CURLE_GOT_NOTHING); // Error code is not used anyway.
remove_easy_request(*iter);
}
delete mWritePollSet;
@@ -1848,7 +1848,9 @@ CURLMcode MultiHandle::remove_easy_request(addedEasyRequests_type::iterator cons
res = curl_easy_request_w->remove_handle_from_multi(curl_easy_request_w, mMultiHandle);
capability_type = curl_easy_request_w->capability_type();
per_service = curl_easy_request_w->getPerServicePtr();
PerService_wat(*per_service)->removed_from_multi_handle(capability_type, downloaded_something); // (About to be) removed from mAddedEasyRequests.
CURLcode code;
curl_easy_request_w->getResult(&code, NULL);
PerService_wat(*per_service)->removed_from_multi_handle(capability_type, downloaded_something, code == CURLE_OK); // (About to be) removed from mAddedEasyRequests.
#ifdef SHOW_ASSERT
curl_easy_request_w->mRemovedPerCommand = as_per_command;
#endif
@@ -2200,7 +2202,7 @@ void BufferedCurlEasyRequest::update_body_bandwidth(void)
mTotalRawBytes = total_raw_bytes;
// Note that in some cases (like HTTP_PARTIAL_CONTENT), the output of CURLINFO_SIZE_DOWNLOAD lags
// behind and will return 0 the first time, and the value of the previous chunk the next time.
// The last call from MultiHandle::finish_easy_request recorrects this, in that case.
// The last call from MultiHandle::finish_easy_request corrects this, in that case.
if (raw_bytes > 0)
{
U64 const sTime_40ms = curlthread::HTTPTimeout::sTime_10ms >> 2;
@@ -2800,7 +2802,7 @@ AIPerService::Approvement* AIPerService::approveHTTPRequestFor(AIPerServicePtr c
equal = pipelined_requests_per_capability_type == ct.mMaxPipelinedRequests;
increment_threshold = ct.mFlags & ctf_starvation;
decrement_threshold = (ct.mFlags & (ctf_empty | ctf_full)) == ctf_full;
ct.mFlags = 0;
ct.mFlags &= ~(ctf_empty|ctf_full|ctf_starvation);
if (decrement_threshold)
{
if ((int)ct.mMaxPipelinedRequests > ct.mConcurrentConnections)