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.
  • Loading branch information
cpinkham committed Jan 30, 2011
1 parent 21efe67 commit 156e8ba
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mythtv/libs/libmythbase/mythdownloadmanager.cpp
Expand Up @@ -629,10 +629,16 @@ bool MythDownloadManager::downloadNow(MythDownloadInfo *dlInfo, bool deleteInfo)
m_infoLock->unlock(); m_infoLock->unlock();
m_queueWaitCond.wakeAll(); 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(); m_infoLock->lock();
while ((!dlInfo->m_done) && 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_infoLock->unlock();
m_queueWaitLock.lock(); m_queueWaitLock.lock();
Expand Down

0 comments on commit 156e8ba

Please sign in to comment.