]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curl_multi_perform.md: resolve inconsistency
authorBilly O'Neal <bion@microsoft.com>
Tue, 27 Jan 2026 00:03:33 +0000 (16:03 -0800)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 27 Jan 2026 08:07:18 +0000 (09:07 +0100)
... 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

docs/libcurl/curl_multi_perform.md

index 3856e9fd1912a9746289c91ec2182de0d48908c3..06ed4900571d3a7ac90eb0fead4b3b4247b635dc 100644 (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 != CURLM_OK) {
+        fprintf(stderr, "curl_multi_perform() failed, code %d.\n",
+                (int)mresult);
+        break;
+      }
 
-      if(!mresult && still_running)
-        /* wait for activity, timeout or "nothing" */
-        mresult = curl_multi_poll(multi, NULL, 0, 1000, NULL);
+      if(!still_running) {
+        break;
+      }
 
-      if(mresult) {
+      /* 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;
       }
-
-    } while(still_running);  /* if there are still transfers, loop */
+    } /* if there are still transfers, loop */
   }
 }
 ~~~