Skip to content

Commit

Permalink
quotest: work around sporadic sendFile failures
Browse files Browse the repository at this point in the history
The commit adds very naive retries to quotest's DownloadRunner, while
the proper fix for #727 is in the works.
  • Loading branch information
KitsuneRal committed Apr 16, 2024
1 parent d74ee11 commit 9286ab1
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions quotest/quotest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,15 +459,26 @@ struct DownloadRunner {

using result_type = QNetworkReply::NetworkError;

QNetworkReply::NetworkError operator()(int) const
void runRequest(QScopedPointer<QNetworkReply, QScopedPointerDeleteLater>& r,
QEventLoop& el) const
{
QEventLoop el;
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> reply {
NetworkAccessManager::instance()->get(QNetworkRequest(url))
};
r.reset(NetworkAccessManager::instance()->get(QNetworkRequest(url)));
QObject::connect(
reply.data(), &QNetworkReply::finished, &el, [&el] { el.exit(); },
r.data(), &QNetworkReply::finished, &el,
[this, &r, &el] {
if (r->error() != QNetworkReply::NoError)
runRequest(r, el);
else
el.exit();
},
Qt::QueuedConnection);
}

QNetworkReply::NetworkError operator()(int) const
{
thread_local QEventLoop el;
thread_local QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> reply{};
runRequest(reply, el);
el.exec();
return reply->error();
}
Expand Down

0 comments on commit 9286ab1

Please sign in to comment.