summaryrefslogtreecommitdiff
path: root/src/tool_operate.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tool_operate.c')
-rw-r--r--src/tool_operate.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 9b5225853..61f481911 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -1924,8 +1924,13 @@ static CURLcode create_transfers(struct GlobalConfig *global,
static long all_added; /* number of easy handles currently added */
+/*
+ * add_parallel_transfers() sets 'morep' to TRUE if there are more transfers
+ * to add even after this call returns.
+ */
static int add_parallel_transfers(struct GlobalConfig *global,
- CURLM *multi)
+ CURLM *multi,
+ bool *morep)
{
struct per_transfer *per;
CURLcode result;
@@ -1950,6 +1955,7 @@ static int add_parallel_transfers(struct GlobalConfig *global,
per->added = TRUE;
all_added++;
}
+ *morep = per ? TRUE : FALSE;
return CURLE_OK;
}
@@ -1962,16 +1968,17 @@ static CURLcode parallel_transfers(struct GlobalConfig *global,
CURLcode result = CURLE_OK;
int still_running = 1;
struct timeval start = tvnow();
+ bool more_transfers;
multi = curl_multi_init();
if(!multi)
return CURLE_OUT_OF_MEMORY;
- result = add_parallel_transfers(global, multi);
+ result = add_parallel_transfers(global, multi, &more_transfers);
if(result)
return result;
- while(!done && !mcode && still_running) {
+ while(!done && !mcode && (still_running || more_transfers)) {
mcode = curl_multi_poll(multi, NULL, 0, 1000, NULL);
if(!mcode)
mcode = curl_multi_perform(multi, &still_running);
@@ -2003,7 +2010,7 @@ static CURLcode parallel_transfers(struct GlobalConfig *global,
} while(msg);
if(removed)
/* one or more transfers completed, add more! */
- (void)add_parallel_transfers(global, multi);
+ (void)add_parallel_transfers(global, multi, &more_transfers);
}
}