mirror of
https://github.com/curl/curl.git
synced 2026-04-14 21:31:42 +03:00
curl_multi_perform.md: resolve inconsistency
... between curl_multi_perform and curl_multi_wait/poll documentation The `curl_multi_perform` documentation uses integer contextual conversion to `bool` to test the resulting `CURLMcode`, while other functions like `curl_multi_wait` and `curl_multi_poll` test against `CURLM_OK`. (I was initially confused by this as it looked like some docs call curl_multi_wait/poll on error, while some called only on success. But that was my misread, not a docs problem.) Also fixed the example to print which function call failed; previously an error reported by `curl_multi_perform` was printed as a failure of `curl_multi_wait`. Closes #20444
This commit is contained in:
parent
08b31b1c8b
commit
af508e3641
1 changed files with 15 additions and 9 deletions
|
|
@ -73,19 +73,25 @@ int main(void)
|
|||
CURL *curl = curl_easy_init();
|
||||
if(curl) {
|
||||
curl_multi_add_handle(multi, curl);
|
||||
do {
|
||||
for(;;) {
|
||||
CURLMcode mresult = curl_multi_perform(multi, &still_running);
|
||||
|
||||
if(!mresult && still_running)
|
||||
/* wait for activity, timeout or "nothing" */
|
||||
mresult = curl_multi_poll(multi, NULL, 0, 1000, NULL);
|
||||
|
||||
if(mresult) {
|
||||
fprintf(stderr, "curl_multi_poll() failed, code %d.\n", (int)mresult);
|
||||
if(mresult != CURLM_OK) {
|
||||
fprintf(stderr, "curl_multi_perform() failed, code %d.\n",
|
||||
(int)mresult);
|
||||
break;
|
||||
}
|
||||
|
||||
} while(still_running); /* if there are still transfers, loop */
|
||||
if(!still_running) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* wait for activity, timeout or "nothing" */
|
||||
mresult = curl_multi_poll(multi, NULL, 0, 1000, NULL);
|
||||
if(mresult != CURLM_OK) {
|
||||
fprintf(stderr, "curl_multi_poll() failed, code %d.\n", (int)mresult);
|
||||
break;
|
||||
}
|
||||
} /* if there are still transfers, loop */
|
||||
}
|
||||
}
|
||||
~~~
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue