From: James Turner Date: Wed, 18 Sep 2013 21:55:11 +0000 (+0100) Subject: Fix HTTP unit test. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f367627cac99eff873569b0c031730e2b55c192d;p=simgear.git Fix HTTP unit test. Also fix a signed/unsigned warning I caused. --- diff --git a/simgear/io/HTTPClient.cxx b/simgear/io/HTTPClient.cxx index 787b4fac..037b1283 100644 --- a/simgear/io/HTTPClient.cxx +++ b/simgear/io/HTTPClient.cxx @@ -808,12 +808,13 @@ void Client::makeRequest(const Request_ptr& r) ss << host << "-" << port; string connectionId = ss.str(); bool havePending = !d->pendingRequests.empty(); - + ConnectionDict::iterator consEnd = d->connections.end(); + // assign request to an existing Connection. // various options exist here, examined in order if (d->connections.size() >= d->maxConnections) { ConnectionDict::iterator it = d->connections.find(connectionId); - if (it == d->connections.end()) { + if (it == consEnd) { // maximum number of connections active, queue this request // when a connection goes inactive, we'll start this one d->pendingRequests.push_back(r); @@ -828,7 +829,7 @@ void Client::makeRequest(const Request_ptr& r) // there's pressure on the number of connections to keep alive, one // host can't DoS every other. int count = 0; - for (;it->first == connectionId; ++it, ++count) { + for (; (it != consEnd) && (it->first == connectionId); ++it, ++count) { if (havePending || !it->second->isActive()) { con = it->second; break; diff --git a/simgear/io/test_HTTP.cxx b/simgear/io/test_HTTP.cxx index e4c5a7b6..442e9ffd 100644 --- a/simgear/io/test_HTTP.cxx +++ b/simgear/io/test_HTTP.cxx @@ -477,7 +477,9 @@ int main(int argc, char* argv[]) { HTTP::Client cl; - + // force all requests to use the same connection for this test + cl.setMaxConnections(1); + // test URL parsing TestRequest* tr1 = new TestRequest("http://localhost.woo.zar:2000/test1?foo=bar"); COMPARE(tr1->scheme(), "http"); @@ -657,6 +659,7 @@ int main(int argc, char* argv[]) cout << "testing HTTP 1.1 pipelineing" << endl; { + cl.setProxy("", 80); TestRequest* tr = new TestRequest("http://localhost:2000/test1"); HTTP::Request_ptr own(tr); diff --git a/simgear/scene/tsync/terrasync.cxx b/simgear/scene/tsync/terrasync.cxx index 7144b15a..edc1d462 100644 --- a/simgear/scene/tsync/terrasync.cxx +++ b/simgear/scene/tsync/terrasync.cxx @@ -773,7 +773,7 @@ void SGTerraSync::SvnThread::initCompletedTilesPersistentCache() time_t now = time(0); readProperties(_persistentCachePath.str(), cacheRoot); - for (unsigned int i=0; inChildren(); ++i) { + for (int i=0; inChildren(); ++i) { SGPropertyNode* entry = cacheRoot->getChild(i); string tileName = entry->getStringValue("path"); time_t stamp = entry->getIntValue("stamp");