[PATCH 3/3] nl80211: make eloop sockets non-blocking

Johannes Berg johannes at sipsolutions.net
Sat Oct 26 06:23:52 EDT 2013

From: Johannes Berg <johannes.berg at intel.com>

To avoid a problem where the beacon socket occasionally
blocks, mark any sockets on the eloop as non-blocking.
The previous patch reordered the code to never send a
command after a socket was put on the eloop, but now also
invalidate the nl handle pointer while it's on there.

Signed-hostap: Johannes Berg <johannes.berg at intel.com>
 src/drivers/driver_nl80211.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 2021a9c..8ce5c2a 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -139,16 +139,25 @@ static void nl_destroy_handles(struct nl_handle **handle)
 	*handle = NULL;
+#if __WORDSIZE == 64
+#define ELOOP_SOCKET_INVALID	0x8888888888888889ULL
+#define ELOOP_SOCKET_INVALID	0x88888889ULL
 static void nl80211_register_eloop_read(struct nl_handle **handle,
 					eloop_sock_handler handler,
 					void *eloop_data)
+	nl_socket_set_nonblocking(*handle);
 	eloop_register_read_sock(nl_socket_get_fd(*handle), handler,
 				 eloop_data, *handle);
+	*handle = (void *)(((unsigned long)*handle) ^ ELOOP_SOCKET_INVALID);
 static void nl80211_destroy_eloop_handle(struct nl_handle **handle)
+	*handle = (void *)(((unsigned long)*handle) ^ ELOOP_SOCKET_INVALID);

More information about the HostAP mailing list