Permalink
Browse files

Backport fc8e5ee from master.

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 16, 2010
1 parent f36a849 commit 557f3dea97fd9370d3967c43042ef7ddc394e6f8
Showing with 11 additions and 4 deletions.
  1. +11 −4 mythtv/libs/libmythdb/mythdownloadmanager.cpp
@@ -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;
}

0 comments on commit 557f3de

Please sign in to comment.