Permalink
Browse files

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.
  • Loading branch information...
1 parent 21efe67 commit 156e8ba70542a99abd0cea6ab0e39232c86e2e7d @cpinkham cpinkham committed Jan 30, 2011
Showing with 8 additions and 2 deletions.
  1. +8 −2 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();

0 comments on commit 156e8ba

Please sign in to comment.