aboutsummaryrefslogtreecommitdiffstats
path: root/libdash
diff options
context:
space:
mode:
authorMauro Sardara <msardara+fdio@cisco.com>2018-06-11 16:17:14 +0200
committerMauro Sardara <msardara+fdio@cisco.com>2018-06-11 14:21:06 +0000
commit78089ad6898f15bc6a716eb39e3f6087dfd9f553 (patch)
treec5334a74b5285d3460c017bde0cfbc63af6cc7fc /libdash
parent872b2e96a111d6da5f821a6dc61b923f9913b3f3 (diff)
Modify behavior of AbstractChunk::DownloadInternalConnection: don't loop waiting fot the download to be completed, wait curl signalization for proceeding.
Change-Id: I07e1f1044435a8fbbe2a5b3fe4d70b42653e4b0f Signed-off-by: Mauro Sardara <msardara+fdio@cisco.com>
Diffstat (limited to 'libdash')
-rw-r--r--libdash/source/network/AbstractChunk.cpp35
1 files changed, 31 insertions, 4 deletions
diff --git a/libdash/source/network/AbstractChunk.cpp b/libdash/source/network/AbstractChunk.cpp
index 81a3d57c..e626b689 100644
--- a/libdash/source/network/AbstractChunk.cpp
+++ b/libdash/source/network/AbstractChunk.cpp
@@ -155,12 +155,39 @@ void* AbstractChunk::DownloadInternalConnection (void *abstractchunk)
AbstractChunk *chunk = (AbstractChunk *) abstractchunk;
//chunk->response = curl_easy_perform(chunk->curl);
- int u =1;
+ int u = 1;
+ CURLMcode ret_code;
+ int repeats = 0;
- while(chunk->stateManager.State() != REQUEST_ABORT && u)
+ do
{
- curl_multi_perform(chunk->curlm, &u);
- }
+ int numfds;
+
+ ret_code = curl_multi_wait(chunk->curlm, NULL, 0, 1000, &numfds);
+
+ if (ret_code != CURLM_OK)
+ {
+ fprintf(stderr, "CURL Multi Wait failed!!!\n");
+ break;
+ }
+
+ if (numfds == 0)
+ {
+ repeats++;
+ if (repeats > 1)
+ {
+ usleep(100000);
+ }
+ }
+ else
+ {
+ repeats = 0;
+ }
+
+ ret_code = curl_multi_perform(chunk->curlm, &u);
+
+ } while(chunk->stateManager.State() != REQUEST_ABORT && u && ret_code == CURLM_OK);
+
double speed;
double size;
double time;