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:25:19 (GMT)
commit8921ded85a092988be40913750530744bbd8aa34 (patch)
tree58dc8e4a23ea708315741d5d4a1430ad0568486e
parent38938b305171831e4ba8472fafb106cdc6f81d80 (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. (cherry picked from commit 156e8ba70542a99abd0cea6ab0e39232c86e2e7d)
-rw-r--r--mythtv/libs/libmythdb/mythdownloadmanager.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/mythtv/libs/libmythdb/mythdownloadmanager.cpp b/mythtv/libs/libmythdb/mythdownloadmanager.cpp
index 658d1ea..334df60 100644
--- a/mythtv/libs/libmythdb/mythdownloadmanager.cpp
+++ b/mythtv/libs/libmythdb/mythdownloadmanager.cpp
@@ -628,10 +628,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();