1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

ss-srv: destroy accepted clients on ws close

This commit is contained in:
Andy Green 2020-11-24 08:41:57 +00:00
parent b4af4bf025
commit 426623433a
2 changed files with 28 additions and 1 deletions

View file

@ -162,6 +162,20 @@ __lws_free_wsi(struct lws *wsi)
if (!wsi)
return;
#if defined(LWS_WITH_SECURE_STREAMS) && defined(LWS_WITH_SERVER)
if (wsi->for_ss) {
/*
* Make certain it is disconnected from the ss by now
*/
lws_ss_handle_t *h = (lws_ss_handle_t *)wsi->a.opaque_user_data;
if (h) {
h->wsi = NULL;
wsi->a.opaque_user_data = NULL;
}
}
#endif
__lws_reset_wsi(wsi);
__lws_wsi_remove_from_sul(wsi);
@ -497,6 +511,7 @@ just_kill_connection:
#if defined(LWS_WITH_SECURE_STREAMS) && defined(LWS_WITH_SERVER)
if (wsi->for_ss) {
lwsl_debug("%s: for_ss\n", __func__);
/*
* We were adopted for a particular ss, but, eg, we may not
* have succeeded with the connection... we are closing which is
@ -505,7 +520,7 @@ just_kill_connection:
*/
lws_ss_handle_t *h = (lws_ss_handle_t *)wsi->a.opaque_user_data;
if (h) {
if (h && !(h->info.flags & LWSSSINFLAGS_ACCEPTED)) {
h->wsi = NULL;
wsi->a.opaque_user_data = NULL;
}

View file

@ -86,6 +86,18 @@ secstream_ws(struct lws *wsi, enum lws_callback_reasons reason, void *user,
return _lws_ss_handle_state_ret(r, wsi, &h);
break;
}
#if defined(LWS_WITH_SERVER)
if (h->info.flags & LWSSSINFLAGS_ACCEPTED) {
/*
* was an accepted client connection to
* our server, so the stream is over now
*/
lws_ss_destroy(&h);
return 0;
}
#endif
}
break;