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 <huw@qti.qualcomm.com>
&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",