ws: unstick connect-only shutdown
As this mode uses blocking sockets, it must set them back to non-blocking in disconnect to avoid the risk of getting stuck. Closes #10366
This commit is contained in:
parent
097544959a
commit
4c48fb4933
@ -151,7 +151,7 @@ const struct Curl_handler Curl_handler_ws = {
|
||||
http_getsock_do, /* doing_getsock */
|
||||
ZERO_NULL, /* domore_getsock */
|
||||
ZERO_NULL, /* perform_getsock */
|
||||
ZERO_NULL, /* disconnect */
|
||||
Curl_ws_disconnect, /* disconnect */
|
||||
ZERO_NULL, /* readwrite */
|
||||
ZERO_NULL, /* connection_check */
|
||||
ZERO_NULL, /* attach connection */
|
||||
@ -205,7 +205,7 @@ const struct Curl_handler Curl_handler_wss = {
|
||||
http_getsock_do, /* doing_getsock */
|
||||
ZERO_NULL, /* domore_getsock */
|
||||
ZERO_NULL, /* perform_getsock */
|
||||
ZERO_NULL, /* disconnect */
|
||||
Curl_ws_disconnect, /* disconnect */
|
||||
ZERO_NULL, /* readwrite */
|
||||
ZERO_NULL, /* connection_check */
|
||||
ZERO_NULL, /* attach connection */
|
||||
|
||||
@ -765,8 +765,8 @@ struct Curl_handler {
|
||||
/* This function *MAY* be set to a protocol-dependent function that is run
|
||||
* by the curl_disconnect(), as a step in the disconnection. If the handler
|
||||
* is called because the connection has been considered dead,
|
||||
* dead_connection is set to TRUE. The connection is already disassociated
|
||||
* from the transfer here.
|
||||
* dead_connection is set to TRUE. The connection is (again) associated with
|
||||
* the transfer here.
|
||||
*/
|
||||
CURLcode (*disconnect)(struct Curl_easy *, struct connectdata *,
|
||||
bool dead_connection);
|
||||
|
||||
11
lib/ws.c
11
lib/ws.c
@ -710,6 +710,17 @@ void Curl_ws_done(struct Curl_easy *data)
|
||||
Curl_dyn_free(&wsp->buf);
|
||||
}
|
||||
|
||||
CURLcode Curl_ws_disconnect(struct Curl_easy *data,
|
||||
struct connectdata *conn,
|
||||
bool dead_connection)
|
||||
{
|
||||
(void)data;
|
||||
(void)dead_connection;
|
||||
/* make sure this is non-blocking to avoid getting stuck in shutdown */
|
||||
(void)curlx_nonblock(conn->sock[FIRSTSOCKET], TRUE);
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
CURL_EXTERN struct curl_ws_frame *curl_ws_meta(struct Curl_easy *data)
|
||||
{
|
||||
/* we only return something for websocket, called from within the callback
|
||||
|
||||
3
lib/ws.h
3
lib/ws.h
@ -60,6 +60,9 @@ CURLcode Curl_ws_accept(struct Curl_easy *data);
|
||||
|
||||
size_t Curl_ws_writecb(char *buffer, size_t size, size_t nitems, void *userp);
|
||||
void Curl_ws_done(struct Curl_easy *data);
|
||||
CURLcode Curl_ws_disconnect(struct Curl_easy *data,
|
||||
struct connectdata *conn,
|
||||
bool dead_connection);
|
||||
|
||||
#else
|
||||
#define Curl_ws_request(x,y) CURLE_OK
|
||||
|
||||
Loading…
Reference in New Issue
Block a user