Fix possible problem with negative mQueuedCommands

mQueuedCommands was unsigned, but can become shortly negative.
Unfortunately this means I had to remove the assert that
keeps track of possible errors, but I believe that already
has been proven that it works anyway.

The reason it can become negative is because its meaning is
"Number of added ADD (request) commands minus number of REMOVE (request)
commands". Hence, it is incremented when an ADD command is added to the
queue and decremented when that ADD command is removed from the queue.
However, it is first decremented when a REMOVE command is added to the
queue and then incremented again when that REMOVE command is removed
again from the queue. Such a remove command is current extremely rare:
it only happens when curl fails to time out - and the backup timeout of
the statemachine fires after 10 minutes of a curl request being idle.
That should normally only happen if a request never reached curl of
course, and is queued in the curl thread, waiting to be added to curl,
aka: -0-0-1,{...} for 10 minutes...

Now that, in turn should be impossible (since the "don't count long poll
connections) unless the Curl* Debug Setting variables are changed to
wrong values.. but ok, can only guess here.
This commit is contained in:
Aleric Inglewood
2013-10-06 15:27:40 +02:00
parent cfad646748
commit f7614dced3
3 changed files with 6 additions and 5 deletions

View File

@@ -145,7 +145,8 @@ class AIPerService {
queued_request_type mQueuedRequests; // Waiting (throttled) requests.
U16 mApprovedRequests; // The number of approved requests for this CT by approveHTTPRequestFor that were not added to the command queue yet.
U16 mQueuedCommands; // Number of add commands (minus remove commands), for this service, in the command queue.
S16 mQueuedCommands; // Number of add commands (minus remove commands), for this service, in the command queue.
// This value can temporarily become negative when remove commands are added to the queue for add requests that were already processed.
U16 mAdded; // Number of active easy handles with this service.
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;
@@ -268,7 +269,7 @@ class AIPerService {
public:
void added_to_command_queue(AICapabilityType capability_type) { ++mCapabilityType[capability_type].mQueuedCommands; mark_inuse(capability_type); }
void removed_from_command_queue(AICapabilityType capability_type) { llassert(mCapabilityType[capability_type].mQueuedCommands > 0); --mCapabilityType[capability_type].mQueuedCommands; }
void removed_from_command_queue(AICapabilityType capability_type) { --mCapabilityType[capability_type].mQueuedCommands; }
void added_to_multi_handle(AICapabilityType capability_type, bool event_poll); // Called when an easy handle for this service has been added to the multi handle.
void removed_from_multi_handle(AICapabilityType capability_type, bool event_poll,
bool downloaded_something, bool success); // Called when an easy handle for this service is removed again from the multi handle.

View File

@@ -1312,7 +1312,7 @@ void AICurlThread::process_commands(AICurlMultiHandle_wat const& multi_handle_w)
*command_being_processed_w = command_queue_w->commands.front();
command = command_being_processed_w->command();
}
// Update the size: the number netto number of pending requests in the command queue.
// Update the size: the netto number of pending requests in the command queue.
command_queue_w->commands.pop_front();
if (command == cmd_add)
{

View File

@@ -109,14 +109,14 @@ void AIServiceBar::draw()
{
if (col < 2)
{
text = llformat(" | %hu-%hu-%lu,{%hu/%hu,%u}/%u",
text = llformat(" | %hu-%hd-%lu,{%hu/%hu,%u}/%u",
ct.mApprovedRequests, ct.mQueuedCommands, ct.mQueuedRequests.size(),
ct.mAdded, ct.mConcurrentConnections, ct.mDownloading,
ct.mMaxPipelinedRequests);
}
else
{
text = llformat(" | --%hu-%lu,{%hu/%hu,%u}",
text = llformat(" | --%hd-%lu,{%hu/%hu,%u}",
ct.mQueuedCommands, ct.mQueuedRequests.size(),
ct.mAdded, ct.mConcurrentConnections, ct.mDownloading);
}