From 68de449093fde6f0612a3a1adef0a559f0195d45 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Mon, 2 Dec 2019 06:55:37 +0000 Subject: [PATCH] raw: client: make sure we get CONNECT and opaque_user_data before RX --- lib/core-net/connect.c | 3 ++- lib/roles/raw-skt/ops-raw-skt.c | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/core-net/connect.c b/lib/core-net/connect.c index 12eb2a25b..91353c2b8 100644 --- a/lib/core-net/connect.c +++ b/lib/core-net/connect.c @@ -227,7 +227,8 @@ lws_client_connect_via_info(const struct lws_client_connect_info *i) /* all the pointers default to NULL, but no need to zero the args */ memset(wsi->stash, 0, sizeof(*wsi->stash)); - wsi->stash->opaque_user_data = i->opaque_user_data; + wsi->opaque_user_data = wsi->stash->opaque_user_data = + i->opaque_user_data; pc = (char *)&wsi->stash[1]; for (n = 0; n < CIS_COUNT; n++) diff --git a/lib/roles/raw-skt/ops-raw-skt.c b/lib/roles/raw-skt/ops-raw-skt.c index ab660230e..0f957cdb4 100644 --- a/lib/roles/raw-skt/ops-raw-skt.c +++ b/lib/roles/raw-skt/ops-raw-skt.c @@ -67,6 +67,8 @@ rops_handle_POLLIN_raw_skt(struct lws_context_per_thread *pt, struct lws *wsi, if ((pollfd->revents & pollfd->events & LWS_POLLIN) && /* any tunnel has to have been established... */ lwsi_state(wsi) != LRS_SSL_ACK_PENDING && + /* we are actually connected */ + lwsi_state(wsi) != LRS_WAITING_CONNECT && !(wsi->favoured_pollin && (pollfd->revents & pollfd->events & LWS_POLLOUT))) { @@ -137,8 +139,9 @@ try_pollout: return LWS_HPI_RET_HANDLED; #if defined(LWS_WITH_CLIENT) - if (lwsi_state(wsi) == LRS_WAITING_CONNECT) - lws_client_connect_4_established(wsi, NULL, 0); + if (lwsi_state(wsi) == LRS_WAITING_CONNECT && + !lws_client_connect_3_connect(wsi, NULL, NULL, 0, NULL)) + return LWS_HPI_RET_WSI_ALREADY_DIED; #endif /* one shot */