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:
Billy O'Neal 2026-01-26 16:03:33 -08:00 committed by Daniel Stenberg
parent 08b31b1c8b
commit af508e3641
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -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 */
}
}
~~~