Skip to content

Commit

Permalink
Backport fc8e5ee from master.
Browse files Browse the repository at this point in the history
MythDownloadManager timeout change and error handling.

- Change the downloadNow() timeout to 10 seconds instead of 20.

- If a downloadNow() request times out, abort the download and
  set a flag which allows the downloadInfo instance to be cleaned
  up by the regular event handlers.
  • Loading branch information
cpinkham committed Dec 29, 2010
1 parent f36a849 commit 557f3de
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions mythtv/libs/libmythdb/mythdownloadmanager.cpp
Expand Up @@ -613,25 +613,32 @@ bool MythDownloadManager::downloadNow(MythDownloadInfo *dlInfo, bool deleteInfo)
m_infoLock->unlock();
m_queueWaitCond.wakeAll();

// sleep for 200ms at a time for up to 20 seconds waiting for the download
// sleep for 200ms at a time for up to 10 seconds waiting for the download
m_infoLock->lock();
while ((!dlInfo->m_done) &&
(dlInfo->m_lastStat.secsTo(QDateTime::currentDateTime()) < 20))
(dlInfo->m_lastStat.secsTo(QDateTime::currentDateTime()) < 10))
{
m_infoLock->unlock();
m_queueWaitLock.lock();
m_queueWaitCond.wait(&m_queueWaitLock, 200);
m_queueWaitLock.unlock();
m_infoLock->lock();
}
m_infoLock->unlock();

bool success =
dlInfo->m_done && (dlInfo->m_errorCode == QNetworkReply::NoError);

if (deleteInfo)
if (!dlInfo->m_done)
{
dlInfo->m_syncMode = false; // Let downloadFinished() cleanup for us
if (dlInfo->m_reply)
dlInfo->m_reply->abort();
}
else if (deleteInfo)
delete dlInfo;

m_infoLock->unlock();

return success;
}

Expand Down

0 comments on commit 557f3de

Please sign in to comment.