move asset retry debug to print before retry

This commit is contained in:
Stephen Birarda 2016-04-20 16:26:35 -07:00
parent 48fcaf9e4b
commit 3a8c2144bf

View file

@ -514,8 +514,17 @@ void Resource::init() {
}
}
const int MAX_ATTEMPTS = 8;
void Resource::attemptRequest() {
_startedLoading = true;
auto timer = qobject_cast<QTimer*>(sender());
if (timer) {
qCDebug(networking).nospace() << "Server unavailable for" << _url
<< "- retrying asset load after" << timer->interval() << "ms - attempt" << _attempts << " of " << MAX_ATTEMPTS;
}
ResourceCache::attemptRequest(_self);
}
@ -602,13 +611,10 @@ void Resource::handleReplyFinished() {
}
case ResourceRequest::Result::ServerUnavailable: {
// retry with increasing delays
const int MAX_ATTEMPTS = 8;
const int BASE_DELAY_MS = 1000;
if (_attempts++ < MAX_ATTEMPTS) {
auto waitTime = BASE_DELAY_MS * (int)pow(2.0, _attempts);
qCDebug(networking) << "Server unavailable for" << _url <<
"retrying in " << waitTime << "ms," <<
"attempt " << _attempts + 1 << "of" << MAX_ATTEMPTS;
QTimer::singleShot(waitTime, this, &Resource::attemptRequest);
break;
}