Skip to content

Commit

Permalink
Add a timeout for RemoteFile sync. downloads in MythDownloadManager
Browse files Browse the repository at this point in the history
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 156e8ba)
  • Loading branch information
cpinkham committed Jan 30, 2011
1 parent 38938b3 commit 8921ded
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mythtv/libs/libmythdb/mythdownloadmanager.cpp
Expand Up @@ -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();
Expand Down

0 comments on commit 8921ded

Please sign in to comment.