[PATCH V2] Handle EAGAIN in wpa_supplicant_ctrl_iface_send

Pontus Fuchs pontus.fuchs at gmail.com
Mon Sep 23 04:17:05 EDT 2013


If a burst of events are sent, the socket queue can overflow and
sendmsg fails with EAGAIN. When this happens the monitor is silently
detached.

Signed-hostap: Pontus Fuchs <pontus.fuchs at gmail.com>
---

V2: Update commit msg.

 wpa_supplicant/ctrl_iface_unix.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/wpa_supplicant/ctrl_iface_unix.c b/wpa_supplicant/ctrl_iface_unix.c
index 49489d6..2c67b9c 100644
--- a/wpa_supplicant/ctrl_iface_unix.c
+++ b/wpa_supplicant/ctrl_iface_unix.c
@@ -623,14 +623,21 @@ static void wpa_supplicant_ctrl_iface_send(const char *ifname, int sock,
 			msg.msg_name = (void *) &dst->addr;
 			msg.msg_namelen = dst->addrlen;
 			if (sendmsg(sock, &msg, MSG_DONTWAIT) < 0) {
-				int _errno = errno;
+				int _errno = errno, detach = 0;
 				wpa_printf(MSG_INFO, "CTRL_IFACE monitor[%d]: "
 					   "%d - %s",
 					   idx, errno, strerror(errno));
 				dst->errors++;
-				if (dst->errors > 1000 ||
-				    (_errno != ENOBUFS && dst->errors > 10) ||
-				    _errno == ENOENT) {
+				if (dst->errors > 1000 || _errno == ENOENT)
+					detach = 1;
+				if (!(_errno == ENOBUFS || _errno == EAGAIN ||
+				    _errno == EWOULDBLOCK) && dst->errors > 10)
+					detach = 1;
+				if (detach) {
+					wpa_printf(MSG_ERROR, "CTRL_IFACE "
+						   "monitor[%d]: Too many "
+						   "errors. Detaching. ",
+						   idx);
 					wpa_supplicant_ctrl_iface_detach(
 						ctrl_dst, &dst->addr,
 						dst->addrlen);
-- 
1.8.1.2



More information about the HostAP mailing list