mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 03:08:00 +02:00
move asset retry debug to print before retry
This commit is contained in:
parent
48fcaf9e4b
commit
3a8c2144bf
1 changed files with 10 additions and 4 deletions
|
@ -514,8 +514,17 @@ void Resource::init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int MAX_ATTEMPTS = 8;
|
||||||
|
|
||||||
void Resource::attemptRequest() {
|
void Resource::attemptRequest() {
|
||||||
_startedLoading = true;
|
_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);
|
ResourceCache::attemptRequest(_self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,13 +611,10 @@ void Resource::handleReplyFinished() {
|
||||||
}
|
}
|
||||||
case ResourceRequest::Result::ServerUnavailable: {
|
case ResourceRequest::Result::ServerUnavailable: {
|
||||||
// retry with increasing delays
|
// retry with increasing delays
|
||||||
const int MAX_ATTEMPTS = 8;
|
|
||||||
const int BASE_DELAY_MS = 1000;
|
const int BASE_DELAY_MS = 1000;
|
||||||
if (_attempts++ < MAX_ATTEMPTS) {
|
if (_attempts++ < MAX_ATTEMPTS) {
|
||||||
auto waitTime = BASE_DELAY_MS * (int)pow(2.0, _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);
|
QTimer::singleShot(waitTime, this, &Resource::attemptRequest);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue