summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Pinkham <cpinkham@mythtv.org>2010-12-16 15:56:04 (GMT)
committer Chris Pinkham <cpinkham@mythtv.org>2010-12-29 15:59:37 (GMT)
commit557f3dea97fd9370d3967c43042ef7ddc394e6f8 (patch)
tree0c9ce7a1078c389396cd6eb6c914871856e79fc0
parentf36a849e83a854b3597a4a25a88aa0cbb5fd9179 (diff)
Backport fc8e5ee from master.
MythDownloadManager timeout change and error handling. - Change the downloadNow() timeout to 10 seconds instead of 20. - If a downloadNow() request times out, abort the download and set a flag which allows the downloadInfo instance to be cleaned up by the regular event handlers.
-rw-r--r--mythtv/libs/libmythdb/mythdownloadmanager.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/mythtv/libs/libmythdb/mythdownloadmanager.cpp b/mythtv/libs/libmythdb/mythdownloadmanager.cpp
index faee531..8b765e7 100644
--- a/mythtv/libs/libmythdb/mythdownloadmanager.cpp
+++ b/mythtv/libs/libmythdb/mythdownloadmanager.cpp
@@ -613,10 +613,10 @@ bool MythDownloadManager::downloadNow(MythDownloadInfo *dlInfo, bool deleteInfo)
m_infoLock->unlock();
m_queueWaitCond.wakeAll();
- // sleep for 200ms at a time for up to 20 seconds waiting for the download
+ // sleep for 200ms at a time for up to 10 seconds waiting for the download
m_infoLock->lock();
while ((!dlInfo->m_done) &&
- (dlInfo->m_lastStat.secsTo(QDateTime::currentDateTime()) < 20))
+ (dlInfo->m_lastStat.secsTo(QDateTime::currentDateTime()) < 10))
{
m_infoLock->unlock();
m_queueWaitLock.lock();
@@ -624,14 +624,21 @@ bool MythDownloadManager::downloadNow(MythDownloadInfo *dlInfo, bool deleteInfo)
m_queueWaitLock.unlock();
m_infoLock->lock();
}
- m_infoLock->unlock();
bool success =
dlInfo->m_done && (dlInfo->m_errorCode == QNetworkReply::NoError);
- if (deleteInfo)
+ if (!dlInfo->m_done)
+ {
+ dlInfo->m_syncMode = false; // Let downloadFinished() cleanup for us
+ if (dlInfo->m_reply)
+ dlInfo->m_reply->abort();
+ }
+ else if (deleteInfo)
delete dlInfo;
+ m_infoLock->unlock();
+
return success;
}