mirror of
https://github.com/cmclark00/retro-imager.git
synced 2025-05-18 16:05:21 +01:00
Reconnect if download stalls for more than one minute
This commit is contained in:
parent
3017bc5fda
commit
abeef65e7d
1 changed files with 7 additions and 2 deletions
|
@ -339,6 +339,9 @@ void DownloadThread::run()
|
||||||
curl_easy_setopt(_c, CURLOPT_FAILONERROR, 1);
|
curl_easy_setopt(_c, CURLOPT_FAILONERROR, 1);
|
||||||
curl_easy_setopt(_c, CURLOPT_HEADERFUNCTION, &DownloadThread::_curl_header_callback);
|
curl_easy_setopt(_c, CURLOPT_HEADERFUNCTION, &DownloadThread::_curl_header_callback);
|
||||||
curl_easy_setopt(_c, CURLOPT_HEADERDATA, this);
|
curl_easy_setopt(_c, CURLOPT_HEADERDATA, this);
|
||||||
|
curl_easy_setopt(_c, CURLOPT_CONNECTTIMEOUT, 30);
|
||||||
|
curl_easy_setopt(_c, CURLOPT_LOW_SPEED_TIME, 60);
|
||||||
|
curl_easy_setopt(_c, CURLOPT_LOW_SPEED_LIMIT, 100);
|
||||||
if (_inputBufferSize)
|
if (_inputBufferSize)
|
||||||
curl_easy_setopt(_c, CURLOPT_BUFFERSIZE, _inputBufferSize);
|
curl_easy_setopt(_c, CURLOPT_BUFFERSIZE, _inputBufferSize);
|
||||||
|
|
||||||
|
@ -352,8 +355,9 @@ void DownloadThread::run()
|
||||||
CURLcode ret = curl_easy_perform(_c);
|
CURLcode ret = curl_easy_perform(_c);
|
||||||
|
|
||||||
/* Deal with badly configured HTTP servers that terminate the connection quickly
|
/* Deal with badly configured HTTP servers that terminate the connection quickly
|
||||||
if connections stalls for some seconds while kernel commits buffers to slow SD card */
|
if connections stalls for some seconds while kernel commits buffers to slow SD card.
|
||||||
while (ret == CURLE_PARTIAL_FILE)
|
And also reconnect if we detect from our end that transfer stalled for more than one minute */
|
||||||
|
while (ret == CURLE_PARTIAL_FILE || ret == CURLE_OPERATION_TIMEDOUT)
|
||||||
{
|
{
|
||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
qDebug() << "HTTP connection lost. Time:" << t;
|
qDebug() << "HTTP connection lost. Time:" << t;
|
||||||
|
@ -602,6 +606,7 @@ void DownloadThread::_onDownloadSuccess()
|
||||||
|
|
||||||
void DownloadThread::_onDownloadError(const QString &msg)
|
void DownloadThread::_onDownloadError(const QString &msg)
|
||||||
{
|
{
|
||||||
|
_cancelled = true;
|
||||||
emit error(msg);
|
emit error(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue