From d84394efa0c8344b2c7bc0f69435a700bf865ae4 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 6 Nov 2013 15:11:46 -0800 Subject: [PATCH] Tweak HTTP code to always sleep. 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 | 8 ++++++-- simgear/io/SVNRepository.cxx | 3 ++- simgear/io/sg_netChannel.hxx | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/simgear/io/HTTPClient.cxx b/simgear/io/HTTPClient.cxx index ed21f284..b7e19917 100644 --- a/simgear/io/HTTPClient.cxx +++ b/simgear/io/HTTPClient.cxx @@ -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; diff --git a/simgear/io/SVNRepository.cxx b/simgear/io/SVNRepository.cxx index a896b3e9..cd0f378f 100644 --- a/simgear/io/SVNRepository.cxx +++ b/simgear/io/SVNRepository.cxx @@ -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; } diff --git a/simgear/io/sg_netChannel.hxx b/simgear/io/sg_netChannel.hxx index bf28a730..538618c3 100644 --- a/simgear/io/sg_netChannel.hxx +++ b/simgear/io/sg_netChannel.hxx @@ -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); }; -- 2.39.5