]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib2305: deal with CURLE_AGAIN
authorDaniel Stenberg <daniel@haxx.se>
Thu, 16 Mar 2023 17:11:44 +0000 (18:11 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 16 Mar 2023 22:29:12 +0000 (23:29 +0100)
The test does a slightly ugly busy-loop for this case but should be
managable due to it likely being a very short moment.

Mention CURLE_AGAIN in curl_ws_recv.3

Fixes #10760
Reported-by: Jay Satiro
Closes #10781

docs/libcurl/curl_ws_recv.3
tests/libtest/lib2305.c

index 5c31367bb65cffffd2ae9b2f8b5432ab09a9d362..487027145e605f81e7032461a41408ba0558bfe3 100644 (file)
@@ -59,6 +59,10 @@ Added in 7.86.0.
 Returns \fBCURLE_OK\fP if everything is okay, and a non-zero number for
 errors. Returns \fBCURLE_GOT_NOTHING\fP if the associated connection is
 closed.
+
+Instead of blocking, the function returns \fBCURLE_AGAIN\fP. The correct
+behavior is then to wait for the socket to signal readability before calling
+this function again.
 .SH "SEE ALSO"
 .BR curl_easy_setopt "(3), " curl_easy_perform "(3), "
 .BR curl_easy_getinfo "(3), "
index 8642ed2794bc9659b3addab70a15e9a2a2e00b73..ebf9bcdbbb6f3239b610440f916059ca05001857 100644 (file)
@@ -52,6 +52,9 @@ static void websocket(CURL *curl)
     CURLcode result =
       curl_ws_recv(curl, buffer, sizeof(buffer), &nread, &meta);
     if(result) {
+      if(result == CURLE_AGAIN)
+        /* crude busy-loop */
+        continue;
       printf("curl_ws_recv returned %d\n", (int)result);
       return;
     }