Reconnect if download stalls for more than one minute
This commit is contained in:
+7
-2
@@ -339,6 +339,9 @@ void DownloadThread::run()
|
||||
curl_easy_setopt(_c, CURLOPT_FAILONERROR, 1);
|
||||
curl_easy_setopt(_c, CURLOPT_HEADERFUNCTION, &DownloadThread::_curl_header_callback);
|
||||
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)
|
||||
curl_easy_setopt(_c, CURLOPT_BUFFERSIZE, _inputBufferSize);
|
||||
|
||||
@@ -352,8 +355,9 @@ void DownloadThread::run()
|
||||
CURLcode ret = curl_easy_perform(_c);
|
||||
|
||||
/* 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 */
|
||||
while (ret == CURLE_PARTIAL_FILE)
|
||||
if connections stalls for some seconds while kernel commits buffers to slow SD card.
|
||||
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);
|
||||
qDebug() << "HTTP connection lost. Time:" << t;
|
||||
@@ -602,6 +606,7 @@ void DownloadThread::_onDownloadSuccess()
|
||||
|
||||
void DownloadThread::_onDownloadError(const QString &msg)
|
||||
{
|
||||
_cancelled = true;
|
||||
emit error(msg);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user