summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2021-01-05 11:48:36 +0100
committerUwe Klotz <uklotz@mixxx.org>2021-01-05 12:19:29 +0100
commit9e3985ff354bc83dd6c77704bec6729bd4017504 (patch)
treee07819b629a495b8689a7db9cc36caa6550a7e84 /src/network
parent0c4736444d205a3910b1667c20e0b191144c52fc (diff)
WebTask: Gracefully handle delayed network replies
Diffstat (limited to 'src/network')
-rw-r--r--src/network/webtask.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/network/webtask.cpp b/src/network/webtask.cpp
index 242a21bf32..99e779d1cc 100644
--- a/src/network/webtask.cpp
+++ b/src/network/webtask.cpp
@@ -252,22 +252,35 @@ void WebTask::slotNetworkReplyFinished() {
return;
}
- VERIFY_OR_DEBUG_ASSERT(m_state == State::Pending) {
- DEBUG_ASSERT(m_timeoutTimerId == kInvalidTimerId);
- return;
- }
-
if (m_timeoutTimerId != kInvalidTimerId) {
killTimer(m_timeoutTimerId);
m_timeoutTimerId = kInvalidTimerId;
}
+ if (m_state != State::Pending) {
+ kLogger.debug()
+ << this
+ << "Discarding obsolete network reply"
+ << pFinishedNetworkReply;
+ if (m_state == State::Aborting) {
+ const auto requestUrl = pPendingNetworkReply->request().url();
+ emitAborted(requestUrl);
+ } else {
+ // Might have been aborted or timed out in the meantime
+ DEBUG_ASSERT(
+ m_state == State::Aborted ||
+ m_state == State::TimedOut);
+ }
+ return;
+ }
+
if (pFinishedNetworkReply->error() != QNetworkReply::NetworkError::NoError) {
onNetworkError(
pFinishedNetworkReply->request().url(),
pFinishedNetworkReply->error(),
pFinishedNetworkReply->errorString(),
pFinishedNetworkReply->readAll());
+ DEBUG_ASSERT(m_state != State::Pending);
return;
}