From 905559c650b2d0d1453a060090f05b9b7c6b9940 Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Fri, 15 Dec 2023 02:16:44 +0530 Subject: [PATCH] [nrf noup] zephyr: Handle socket close fixup! [nrf noup] zephyr: Add support for WPA CLI zephyr In some cases (interface is disabled) the control interface socket is closed but as we don't handle EoF control interface keeps receiving zero bytes from the socket continuously and this causes an infinite loop and starving other threads (even SHELL thread). So, treat 0 bytes recv as EoF as its a connected socket and unregister from eloop to avoid infinite loop of recv failures. Signed-off-by: Chaitanya Tata --- wpa_supplicant/ctrl_iface_zephyr.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wpa_supplicant/ctrl_iface_zephyr.c b/wpa_supplicant/ctrl_iface_zephyr.c index 566381b41..b33b100aa 100644 --- a/wpa_supplicant/ctrl_iface_zephyr.c +++ b/wpa_supplicant/ctrl_iface_zephyr.c @@ -135,6 +135,13 @@ static void wpa_supplicant_ctrl_iface_receive(int sock, void *eloop_ctx, os_free(buf); return; } + if (!res) { + eloop_unregister_sock(sock); + wpa_printf(MSG_DEBUG, "ctrl_iface: Peer unexpectedly shut down " + "socket"); + os_free(buf); + return; + } if ((size_t) res > CTRL_IFACE_MAX_LEN) { wpa_printf(MSG_ERROR, "recvform(ctrl_iface): input truncated");