diff --git a/modules/iswa/rendering/dataplane.cpp b/modules/iswa/rendering/dataplane.cpp index cdf093238b..6a0fb71699 100644 --- a/modules/iswa/rendering/dataplane.cpp +++ b/modules/iswa/rendering/dataplane.cpp @@ -184,7 +184,9 @@ bool DataPlane::loadTexture() { } bool DataPlane::updateTexture(){ - if(_futureObject) + + // If a download is in progress, dont send another request. + if(_futureObject && !_futureObject->isFinished && !_futureObject->isAborted) return false; _memorybuffer = ""; diff --git a/modules/iswa/rendering/screenspacecygnet.cpp b/modules/iswa/rendering/screenspacecygnet.cpp index 66ad563d84..12fe36f3bf 100644 --- a/modules/iswa/rendering/screenspacecygnet.cpp +++ b/modules/iswa/rendering/screenspacecygnet.cpp @@ -136,8 +136,7 @@ bool ScreenSpaceCygnet::isReady() const{ void ScreenSpaceCygnet::updateTexture(){ // If a download is in progress, dont send another request. - //What if image failed to download? - if(_futureTexture && !_futureTexture->isFinished) + if(_futureTexture && !_futureTexture->isFinished && !_futureTexture->isAborted) return; _memorybuffer = ""; diff --git a/modules/iswa/rendering/textureplane.cpp b/modules/iswa/rendering/textureplane.cpp index 9a33fd3679..4b371e1a75 100644 --- a/modules/iswa/rendering/textureplane.cpp +++ b/modules/iswa/rendering/textureplane.cpp @@ -111,7 +111,9 @@ bool TexturePlane::loadTexture() { bool TexturePlane::updateTexture(){ - if(_futureObject) + + // If a download is in progress, dont send another request. + if(_futureObject && !_futureObject->isFinished && !_futureObject->isAborted) return false; _memorybuffer = ""; diff --git a/modules/iswa/util/iswamanager.cpp b/modules/iswa/util/iswamanager.cpp index b43f042aeb..0ca08bf292 100644 --- a/modules/iswa/util/iswamanager.cpp +++ b/modules/iswa/util/iswamanager.cpp @@ -125,10 +125,14 @@ void ISWAManager::addISWACygnet(int id, std::string info, int group){ auto metadataCallback = [this, metaFuture](const DownloadManager::FileFuture& f){ - LDEBUG("Download to memory finished"); - metaFuture->isFinished = true; - createPlane(metaFuture); - }; + if(f.isFinished){ + metaFuture->isFinished; + createPlane(metaFuture); + LDEBUG("Download to memory finished"); + } else if (f.isAborted){ + LWARNING("Download to memory was aborted: " + f.errorMessage); + } + }; // Download metadata DlManager.downloadToMemory( @@ -163,7 +167,11 @@ std::shared_ptr ISWAManager::downloadImageToMemory( iSWAurl(id, "image"), buffer, [](const DownloadManager::FileFuture& f){ - LDEBUG("Download to memory finished"); + if(f.isFinished){ + LDEBUG("Download to memory finished"); + } else if (f.isAborted){ + LWARNING("Download to memory was aborted: " + f.errorMessage); + } } ); } @@ -173,7 +181,11 @@ std::shared_ptr ISWAManager::downloadDataToMemory(i iSWAurl(id, "data"), buffer, [](const DownloadManager::FileFuture& f){ - LDEBUG("Download data finished"); + if(f.isFinished){ + LDEBUG("Download to memory finished"); + } else if (f.isAborted){ + LWARNING("Download to memory was aborted: " + f.errorMessage); + } } ); } @@ -213,8 +225,12 @@ std::shared_ptr ISWAManager::downloadMetadata(int id){ // "http://10.0.0.76:3000/" + std::to_string(-id), metaFuture->json, [metaFuture](const DownloadManager::FileFuture& f){ - LDEBUG("Download to memory finished"); - metaFuture->isFinished = true; + if(f.isFinished){ + metaFuture->isFinished; + LDEBUG("Download to memory finished"); + } else if (f.isAborted){ + LWARNING("Download to memory was aborted: " + f.errorMessage); + } } ); return metaFuture; diff --git a/src/engine/downloadmanager.cpp b/src/engine/downloadmanager.cpp index ba8d5ae496..7af3b084e8 100644 --- a/src/engine/downloadmanager.cpp +++ b/src/engine/downloadmanager.cpp @@ -227,26 +227,27 @@ std::shared_ptr DownloadManager::downloadToMemory( curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, xferinfo); curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &p); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); + curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5L); CURLcode res = curl_easy_perform(curl); if(res == CURLE_OK){ // ask for the content-type char *ct; res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct); - if(ct){ + if (res == CURLE_OK){ future->format = std::string(ct); - } - } - - curl_easy_cleanup(curl); - - if (res == CURLE_OK) - future->isFinished = true; - else + future->isFinished = true; + } + } else{ future->errorMessage = curl_easy_strerror(res); - + future->isAborted = true; + } + if (finishedCallback) finishedCallback(*future); + + curl_easy_cleanup(curl); + } };