summaryrefslogtreecommitdiff
path: root/lib/ws.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2022-12-12 13:37:55 +0100
committerDaniel Stenberg <daniel@haxx.se>2022-12-13 15:13:03 +0100
commit734c1f8909d75549a36c604796098cd117826e06 (patch)
tree560fe2129145ddfbb9ec58ed8b3bfd84504d7cfe /lib/ws.c
parent845f020ea5e18ae0336ea7528546ee033a966eea (diff)
downloadcurl-734c1f8909d75549a36c604796098cd117826e06.tar.gz
ws: if no connection is around, return error
- curl_ws_send returns CURLE_SEND_ERROR if data->conn is gone - curl_ws_recv returns CURLE_GOT_NOTHING on connection close - curl_ws_recv.3: mention new return code for connection close + example embryo Closes #10084
Diffstat (limited to 'lib/ws.c')
-rw-r--r--lib/ws.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/ws.c b/lib/ws.c
index 708504ba6..c1b2622a7 100644
--- a/lib/ws.c
+++ b/lib/ws.c
@@ -420,8 +420,8 @@ CURL_EXTERN CURLcode curl_ws_recv(struct Curl_easy *data, void *buffer,
if(result)
return result;
if(!n)
- /* still have nothing */
- goto out;
+ /* connection closed */
+ return CURLE_GOT_NOTHING;
wsp->stillb = data->state.buffer;
wsp->stillblen = n;
}
@@ -483,7 +483,6 @@ CURL_EXTERN CURLcode curl_ws_recv(struct Curl_easy *data, void *buffer,
wsp->stillb = NULL;
}
}
-out:
*metap = &wsp->frame;
return CURLE_OK;
}
@@ -632,9 +631,14 @@ CURL_EXTERN CURLcode curl_ws_send(struct Curl_easy *data, const void *buffer,
return CURLE_OK;
/* raw mode sends exactly what was requested, and this is from within
the write callback */
- if(Curl_is_in_callback(data))
+ if(Curl_is_in_callback(data)) {
+ if(!data->conn) {
+ failf(data, "No associated connection");
+ return CURLE_SEND_ERROR;
+ }
result = Curl_write(data, data->conn->writesockfd, buffer, buflen,
&written);
+ }
else
result = Curl_senddata(data, buffer, buflen, &written);