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)
This commit is contained in:
James Turner
2013-11-06 15:11:46 -08:00
parent dd613d48bc
commit d84394efa0
3 changed files with 10 additions and 3 deletions
+6 -2
View File
@@ -645,9 +645,13 @@ void Client::setMaxConnections(unsigned int maxCon)
void Client::update(int waitTimeout) void Client::update(int waitTimeout)
{ {
d->poller.poll(waitTimeout); if (!d->poller.hasChannels() && (waitTimeout > 0)) {
bool waitingRequests = !d->pendingRequests.empty(); SGTimeStamp::sleepForMSec(waitTimeout);
} else {
d->poller.poll(waitTimeout);
}
bool waitingRequests = !d->pendingRequests.empty();
ConnectionDict::iterator it = d->connections.begin(); ConnectionDict::iterator it = d->connections.begin();
for (; it != d->connections.end(); ) { for (; it != d->connections.end(); ) {
Connection* con = it->second; Connection* con = it->second;
+2 -1
View File
@@ -73,7 +73,8 @@ public:
void updateFailed(HTTP::Request* req, SVNRepository::ResultCode err) 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; isUpdating = false;
status = err; status = err;
} }
+2
View File
@@ -123,6 +123,8 @@ public:
void addChannel(NetChannel* channel); void addChannel(NetChannel* channel);
void removeChannel(NetChannel* channel); void removeChannel(NetChannel* channel);
bool hasChannels() const { return !channels.empty(); }
bool poll(unsigned int timeout = 0); bool poll(unsigned int timeout = 0);
void loop(unsigned int timeout = 0); void loop(unsigned int timeout = 0);
}; };