From d1d5cf2947d62ce2ed0aeb8c2df34eff857678b1 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Mon, 3 Aug 2020 16:04:03 +0100 Subject: [PATCH] sspc: improve client async close flow --- lib/secure-streams/secure-streams-process.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/secure-streams/secure-streams-process.c b/lib/secure-streams/secure-streams-process.c index 2bfc45af8..86a77af6b 100644 --- a/lib/secure-streams/secure-streams-process.c +++ b/lib/secure-streams/secure-streams-process.c @@ -299,11 +299,22 @@ callback_ss_proxy(struct lws *wsi, enum lws_callback_reasons reason, */ if (conn->ss) { + struct lws *cw = conn->ss->wsi; + /* + * The onward connection is around + */ lwsl_info("%s: destroying ss.h=%p, ss.wsi=%p\n", __func__, conn->ss, conn->ss->wsi); /* sever relationship with ss about to be deleted */ lws_set_opaque_user_data(wsi, NULL); - + if (wsi != cw) + /* + * The wsi doing the onward connection can no + * longer relate to the conn... otherwise when + * he gets callbacks he wants to bind to + * the ss we are about to delete + */ + lws_wsi_close(cw, LWS_TO_KILL_ASYNC); conn->wsi = NULL;