Permalink
Browse files

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...
1 parent 271c60a commit fc8e5eeaee31feaac24cbffaf5a94f33302a3b04 @cpinkham cpinkham committed Dec 16, 2010
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 fc8e5ee

Please sign in to comment.