From c5aaa015627daa1e9fba7065e07294f952b295cf Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 17 Mar 2009 16:56:30 +0200 Subject: [PATCH] Detach ctrl_iface monitor if the client socket is removed No need to wait for 10 errors when using UNIX domain socket; we can detach the client immediately on ENOENT. --- hostapd/ctrl_iface.c | 9 +++++---- wpa_supplicant/ctrl_iface_unix.c | 7 +++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index d24c4af..8251032 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -570,11 +570,12 @@ static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level, msg.msg_name = &dst->addr; msg.msg_namelen = dst->addrlen; if (sendmsg(hapd->ctrl_sock, &msg, 0) < 0) { - fprintf(stderr, "CTRL_IFACE monitor[%d]: ", - idx); - perror("sendmsg"); + int _errno = errno; + wpa_printf(MSG_INFO, "CTRL_IFACE monitor[%d]: " + "%d - %s", + idx, errno, strerror(errno)); dst->errors++; - if (dst->errors > 10) { + if (dst->errors > 10 || _errno == ENOENT) { hostapd_ctrl_iface_detach( hapd, &dst->addr, dst->addrlen); diff --git a/wpa_supplicant/ctrl_iface_unix.c b/wpa_supplicant/ctrl_iface_unix.c index bf6328e..870e9c0 100644 --- a/wpa_supplicant/ctrl_iface_unix.c +++ b/wpa_supplicant/ctrl_iface_unix.c @@ -514,9 +514,12 @@ static void wpa_supplicant_ctrl_iface_send(struct ctrl_iface_priv *priv, msg.msg_name = (void *) &dst->addr; msg.msg_namelen = dst->addrlen; if (sendmsg(priv->sock, &msg, 0) < 0) { - perror("sendmsg(CTRL_IFACE monitor)"); + int _errno = errno; + wpa_printf(MSG_INFO, "CTRL_IFACE monitor[%d]: " + "%d - %s", + idx, errno, strerror(errno)); dst->errors++; - if (dst->errors > 10) { + if (dst->errors > 10 || _errno == ENOENT) { wpa_supplicant_ctrl_iface_detach( priv, &dst->addr, dst->addrlen); -- 2.1.4