summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Pinkham <cpinkham@mythtv.org>2011-01-30 04:59:46 (GMT)
committer Chris Pinkham <cpinkham@mythtv.org>2011-01-30 05:13:36 (GMT)
commit156e8ba70542a99abd0cea6ab0e39232c86e2e7d (patch)
treead17e693226cd671b0230cf8cbd8f8ce1635ac17
parent21efe67d33fe2513b508d5e2d219237d1f65a6a1 (diff)
Add a timeout for RemoteFile sync. downloads in MythDownloadManager
In MythDownloadManager::downloadNow(), add a 20 second timeout for RemoteFile downloads. This allows us to abort a synchronous RemoteFile download if the transfer hangs. RemoteFile does not send back progress updates, so we can't rely on m_lastStat being updated, so we base the timeout on the start time.
-rw-r--r--mythtv/libs/libmythbase/mythdownloadmanager.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/mythtv/libs/libmythbase/mythdownloadmanager.cpp b/mythtv/libs/libmythbase/mythdownloadmanager.cpp
index 4c6bad4..85c7b8a 100644
--- a/mythtv/libs/libmythbase/mythdownloadmanager.cpp
+++ b/mythtv/libs/libmythbase/mythdownloadmanager.cpp
@@ -629,10 +629,16 @@ bool MythDownloadManager::downloadNow(MythDownloadInfo *dlInfo, bool deleteInfo)
m_infoLock->unlock();
m_queueWaitCond.wakeAll();
- // sleep for 200ms at a time for up to 10 seconds waiting for the download
+ // timeout myth:// RemoteFile transfers 20 seconds from now
+ // timeout non-myth:// QNetworkAccessManager transfers 10 seconds after
+ // their last progress update
+ QDateTime startedAt = QDateTime::currentDateTime();
m_infoLock->lock();
while ((!dlInfo->m_done) &&
- (dlInfo->m_lastStat.secsTo(QDateTime::currentDateTime()) < 10))
+ (((!dlInfo->m_url.startsWith("myth://")) &&
+ (dlInfo->m_lastStat.secsTo(QDateTime::currentDateTime()) < 10)) ||
+ ((dlInfo->m_url.startsWith("myth://")) &&
+ (startedAt.secsTo(QDateTime::currentDateTime()) < 20))))
{
m_infoLock->unlock();
m_queueWaitLock.lock();