void testHandleAckRequestReceived_AcksStanza() {
			boost::shared_ptr<StanzaAckResponder> testling(createResponder());
			testling->handleStanzaReceived();

			testling->handleAckRequestReceived();

			CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(acks.size()));
			CPPUNIT_ASSERT_EQUAL(1U, acks[0]);
		}
		void testHandleAckRequestReceived_AcksMultipleStanzas() {
			std::auto_ptr<StanzaAckResponder> testling(createResponder());
			testling->handleStanzaReceived();
			testling->handleStanzaReceived();

			testling->handleAckRequestReceived();

			CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(acks.size()));
			CPPUNIT_ASSERT_EQUAL(2U, acks[0]);
		}
		// Handle stanza ack count wrapping, as per the XEP
		void testHandleAckRequestReceived_WrapAround() {
			boost::shared_ptr<StanzaAckResponder> testling(createResponder());
			testling->handledStanzasCount = boost::numeric_cast<unsigned int>((1ULL<<32) - 1);
			testling->handleStanzaReceived();
			testling->handleStanzaReceived();

			testling->handleAckRequestReceived();

			CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(acks.size()));
			CPPUNIT_ASSERT_EQUAL(1U, acks[0]);
		}
void LLMediaDataClient::serviceQueue()
{	
	request_queue_t *queue_p = getCurrentQueue();
	
	// quick retry loop for cases where we shouldn't wait for the next timer tick
	while(true)
	{
		if (queue_p->empty())
		{
			LL_DEBUGS("LLMediaDataClient") << "queue empty: " << (*queue_p) << LL_ENDL;
			break;
		}
		
		// Peel one off of the items from the queue, and execute request
		request_ptr_t request = queue_p->front();
		llassert(!request.isNull());
		const LLMediaDataClientObject *object = (request.isNull()) ? NULL : request->getObject();
		llassert(NULL != object);
		
		// Check for conditions that would make us just pop and rapidly loop through
		// the queue.
		if(request.isNull() ||
		   request->isMarkedSent() ||
		   NULL == object ||
		   object->isDead() ||
		   !object->hasMedia())
		{
			if (request.isNull()) 
			{
				LL_WARNS("LLMediaDataClient") << "Skipping NULL request" << LL_ENDL;
			}
			else {
				LL_INFOS("LLMediaDataClient") << "Skipping : " << *request << " " 
				<< ((request->isMarkedSent()) ? " request is marked sent" :
					((NULL == object) ? " object is NULL " :
					 ((object->isDead()) ? "object is dead" : 
					  ((!object->hasMedia()) ? "object has no media!" : "BADNESS!")))) << LL_ENDL;
			}
			queue_p->pop_front();
			continue;	// jump back to the start of the quick retry loop
		}
		
		// Next, ask if this is "interesting enough" to fetch.  If not, just stop
		// and wait for the next timer go-round.  Only do this for the sorted 
		// queue.
		if (mCurrentQueueIsTheSortedQueue && !object->isInterestingEnough())
		{
			LL_DEBUGS("LLMediaDataClient") << "Not fetching " << *request << ": not interesting enough" << LL_ENDL;
			break;
		}
		
		// Finally, try to send the HTTP message to the cap url
		std::string url = request->getCapability();
		bool maybe_retry = false;
		if (!url.empty())
		{
			const LLSD &sd_payload = request->getPayload();
			LL_INFOS("LLMediaDataClient") << "Sending request for " << *request << LL_ENDL;
			
			// Call the subclass for creating the responder
			LLHTTPClient::post(url, sd_payload, createResponder(request));
		}
		else {
			LL_INFOS("LLMediaDataClient") << "NOT Sending request for " << *request << ": empty cap url!" << LL_ENDL;
			maybe_retry = true;
		}

		bool exceeded_retries = request->getRetryCount() > mMaxNumRetries;
		if (maybe_retry && ! exceeded_retries) // Try N times before giving up 
		{
			// We got an empty cap, but in that case we will retry again next
			// timer fire.
			request->incRetryCount();
		}
		else {
			if (exceeded_retries)
			{
				LL_WARNS("LLMediaDataClient") << "Could not send request " << *request << " for " 
					<< mMaxNumRetries << " tries...popping object id " << object->getID() << LL_ENDL; 
				// XXX Should we bring up a warning dialog??
			}
			
			queue_p->pop_front();
			
			if (! mCurrentQueueIsTheSortedQueue) {
				// Round robin
				request->markSent(true);
				mRoundRobinQueue.push_back(request);				
			}
		}
		
 		// end of quick loop -- any cases where we want to loop will use 'continue' to jump back to the start.
 		break;
	}
	
	swapCurrentQueue();
}