From 6c11fcefe4fc489b59d5defb0ef4cdd0001a9c28 Mon Sep 17 00:00:00 2001 From: Hu Wang Date: Tue, 5 Aug 2025 23:28:17 -0700 Subject: [PATCH] hostapd: Prevent blocking sends on control interface monitor socket hostapd could experience prolonged blocking when sending events to its control interface monitor clients via sendmsg. This was particularly problematic when a client disconnected abruptly, leaving a stale socket file, causing sendmsg to block for extended periods (e.g., over a minute) before returning an error. An initial attempt to mitigate this involved setting the SO_SNDTIMEO socket option. However, testing on Android/Linux platforms revealed that SO_SNDTIMEO did not reliably prevent the blocking behavior for this specific Unix domain socket use case. Use the MSG_DONTWAIT flag in the sendmsg() calls to ensure that sendmsg operates in a non-blocking mode. This guarantees that hostapd's event processing loop will not become unresponsive due to stuck send operations. This matches what wpa_supplicant was already doing in wpa_supplicant_ctrl_iface_send() as well. Signed-off-by: Hu Wang --- hostapd/ctrl_iface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index 3b410ac77..45c498a34 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -6256,7 +6256,7 @@ static void hostapd_ctrl_iface_send_internal(int sock, struct dl_list *ctrl_dst, &dst->addr, dst->addrlen); msg.msg_name = &dst->addr; msg.msg_namelen = dst->addrlen; - if (sendmsg(sock, &msg, 0) < 0) { + if (sendmsg(sock, &msg, MSG_DONTWAIT) < 0) { int _errno = errno; wpa_printf(MSG_INFO, "CTRL_IFACE monitor[%d]: " "%d - %s", -- 2.47.3