]> git.mxchange.org Git - simgear.git/commitdiff
Fix HTTP unit test.
authorJames Turner <zakalawe@mac.com>
Wed, 18 Sep 2013 21:55:11 +0000 (22:55 +0100)
committerJames Turner <zakalawe@mac.com>
Wed, 18 Sep 2013 21:55:11 +0000 (22:55 +0100)
Also fix a signed/unsigned warning I caused.

simgear/io/HTTPClient.cxx
simgear/io/test_HTTP.cxx
simgear/scene/tsync/terrasync.cxx

index 787b4facc73cc003b4f63da900921deeb86cee88..037b1283677091be09b9f4417855c64dcf806e56 100644 (file)
@@ -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;
index e4c5a7b6f673cfd266891e5c417bf5a6e612c497..442e9ffdbb4c790873d04641770ab5fbd4082fac 100644 (file)
@@ -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);
index 7144b15ab9482ad45134b11961e09aeebb30f253..edc1d46239abc31f0b927d9a9a380aab4b6c6799 100644 (file)
@@ -773,7 +773,7 @@ void SGTerraSync::SvnThread::initCompletedTilesPersistentCache()
     time_t now = time(0);
     
     readProperties(_persistentCachePath.str(), cacheRoot);
-    for (unsigned int i=0; i<cacheRoot->nChildren(); ++i) {
+    for (int i=0; i<cacheRoot->nChildren(); ++i) {
         SGPropertyNode* entry = cacheRoot->getChild(i);
         string tileName = entry->getStringValue("path");
         time_t stamp = entry->getIntValue("stamp");