From 0ca6c26ddb52e83b41c9da0cd8ff8d737dc26452 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. Fixes SHEL-2320. 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..5e17860de 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, EVENT_TYPE_READ); + 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");