websocket: introduce blocking sends

When using `curl_ws_send()`, perform a blocking send of the data under
the following conditions:

- the websocket is in raw mode and the call is done from within a curl
  callback. A partial write of the data could subsequently mess up the
  ws framing, as a callback has a hard time handling this.

- the websocket is encoding the data itself, has added it to its
  internal sendbuf. A partial flush of the buffer has unclear semantics
  for the caller, as they will have no idea what to send again.

Fixes WebSockets tests with CURL_DBG_SOCK_WBLOCK=90 set.
Closes #14458
This commit is contained in:
Stefan Eissing 2024-08-08 16:00:24 +02:00 committed by Daniel Stenberg
parent 0a5ea09a91
commit 3e64569a9e
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
8 changed files with 299 additions and 60 deletions

View file

@ -479,6 +479,8 @@
- curl_multi_remove_handle for any of the above. See section 2.3.
- Calling curl_ws_send() from a callback
2.2 Better support for same name resolves
If a name resolve has been initiated for name NN and a second easy handle

View file

@ -109,6 +109,10 @@ Traces reading of upload data from the application in order to send it to the se
Traces writing of download data, received from the server, to the application.
## `ws`
Tracing of WebSocket operations when this protocol is enabled in your build.
# TRACE GROUPS
Besides the specific component names there are the following group names

View file

@ -53,6 +53,10 @@ If **CURLWS_RAW_MODE** is enabled in CURLOPT_WS_OPTIONS(3), the
To send a message consisting of multiple frames, set the *CURLWS_CONT* bit
in all frames except the final one.
Warning: while it is possible to invoke this function from a callback,
such a call is blocking in this situation, e.g. only returns after all data
has been sent or an error is encountered.
# FLAGS
## CURLWS_TEXT