From 0fc0dcdb798f7bbddb3195cb6afa99c437981491 Mon Sep 17 00:00:00 2001 From: Jim Broadus Date: Sat, 23 May 2020 23:45:08 -0700 Subject: [PATCH] lyrics: Add 30s timeout for lyrics provider requests --- src/songinfo/ultimatelyricsprovider.cpp | 4 ++++ src/songinfo/ultimatelyricsprovider.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/songinfo/ultimatelyricsprovider.cpp b/src/songinfo/ultimatelyricsprovider.cpp index cb0713b79..459a64549 100644 --- a/src/songinfo/ultimatelyricsprovider.cpp +++ b/src/songinfo/ultimatelyricsprovider.cpp @@ -30,6 +30,7 @@ const int UltimateLyricsProvider::kRedirectLimit = 5; UltimateLyricsProvider::UltimateLyricsProvider() : network_(new NetworkAccessManager(this)), + timeouts_(new NetworkTimeouts(30000, this)), // 30s relevance_(0), redirect_count_(0), url_hop_(false) {} @@ -57,6 +58,7 @@ void UltimateLyricsProvider::FetchInfo(int id, const Song& metadata) { QNetworkReply* reply = network_->get(QNetworkRequest(url)); connect(reply, &QNetworkReply::finished, [=] { this->RequestFinished(reply, url_text, id); }); + timeouts_->AddReply(reply); } void UltimateLyricsProvider::RequestFinished(QNetworkReply* reply, @@ -93,6 +95,7 @@ void UltimateLyricsProvider::RequestFinished(QNetworkReply* reply, QNetworkReply* reply = network_->get(QNetworkRequest(target)); connect(reply, &QNetworkReply::finished, [=] { this->RequestFinished(reply, orig_url, id); }); + timeouts_->AddReply(reply); return; } @@ -128,6 +131,7 @@ void UltimateLyricsProvider::RequestFinished(QNetworkReply* reply, QNetworkReply* reply = network_->get(QNetworkRequest(url)); connect(reply, &QNetworkReply::finished, [=] { this->RequestFinished(reply, orig_url, id); }); + timeouts_->AddReply(reply); return; } diff --git a/src/songinfo/ultimatelyricsprovider.h b/src/songinfo/ultimatelyricsprovider.h index 51528f8d0..b48ce3adf 100644 --- a/src/songinfo/ultimatelyricsprovider.h +++ b/src/songinfo/ultimatelyricsprovider.h @@ -25,6 +25,7 @@ #include "songinfoprovider.h" class NetworkAccessManager; +class NetworkTimeouts; class QNetworkReply; @@ -86,6 +87,7 @@ class UltimateLyricsProvider : public SongInfoProvider { private: NetworkAccessManager* network_; + NetworkTimeouts* timeouts_; QString name_; QString title_;