From eb584cf46094383b55c3913af6116540e46cb71c Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 14 Apr 2024 20:19:46 +0200 Subject: [PATCH] quotest: work around sporadic sendFile failures The commit adds very naive retries to quotest's DownloadRunner, while the proper fix for #727 is in the works. --- quotest/quotest.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/quotest/quotest.cpp b/quotest/quotest.cpp index 9bbde3a8b..e0770718e 100644 --- a/quotest/quotest.cpp +++ b/quotest/quotest.cpp @@ -459,15 +459,26 @@ struct DownloadRunner { using result_type = QNetworkReply::NetworkError; - QNetworkReply::NetworkError operator()(int) const + void runRequest(QScopedPointer& r, + QEventLoop& el) const { - QEventLoop el; - QScopedPointer 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 reply{}; + runRequest(reply, el); el.exec(); return reply->error(); }