]> git.mxchange.org Git - simgear.git/commitdiff
Tweak HTTP code to always sleep.
authorJames Turner <zakalawe@mac.com>
Wed, 6 Nov 2013 23:11:46 +0000 (15:11 -0800)
committerJames Turner <zakalawe@mac.com>
Wed, 6 Nov 2013 23:11:46 +0000 (15:11 -0800)
Check explicitly for the 'no channels' case and
sleep instead, to avoid busy-waiting. (This is a work-
around, the underlying issue still be be traced)

simgear/io/HTTPClient.cxx
simgear/io/SVNRepository.cxx
simgear/io/sg_netChannel.hxx

index ed21f284be0183b016a4f5fb9ddd3021826b08be..b7e19917bc315caefa7e43acbc293a0c7101f627 100644 (file)
@@ -645,9 +645,13 @@ void Client::setMaxConnections(unsigned int maxCon)
 
 void Client::update(int waitTimeout)
 {
-    d->poller.poll(waitTimeout);
-    bool waitingRequests = !d->pendingRequests.empty();
+    if (!d->poller.hasChannels() && (waitTimeout > 0)) {
+        SGTimeStamp::sleepForMSec(waitTimeout);
+    } else {
+        d->poller.poll(waitTimeout);
+    }
     
+    bool waitingRequests = !d->pendingRequests.empty();
     ConnectionDict::iterator it = d->connections.begin();
     for (; it != d->connections.end(); ) {
         Connection* con = it->second;
index a896b3e9d8e0886f07d16f87b3dcd78c47c002be..cd0f378f72a6335ff2595605f63e5977961f6810 100644 (file)
@@ -73,7 +73,8 @@ public:
     
     void updateFailed(HTTP::Request* req, SVNRepository::ResultCode err)
     {
-        SG_LOG(SG_IO, SG_WARN, "SVN: failed to update from:" << req->url());
+        SG_LOG(SG_IO, SG_WARN, "SVN: failed to update from:" << req->url()
+            << "\n(repository:" << p->baseUrl() << ")");
         isUpdating = false;
         status = err;
     }
index bf28a730e2da55b0c172cb72bb006036e4962877..538618c3f0187ef930d5d717dfd9d8a434dcdf72 100644 (file)
@@ -123,6 +123,8 @@ public:
     void addChannel(NetChannel* channel);
     void removeChannel(NetChannel* channel);
     
+    bool hasChannels() const { return !channels.empty(); }
+    
     bool poll(unsigned int timeout = 0);
     void loop(unsigned int timeout = 0);
 };