]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Make eloop sockets non-blocking
authorJohannes Berg <johannes.berg@intel.com>
Sat, 26 Oct 2013 13:09:56 +0000 (16:09 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 26 Oct 2013 14:48:22 +0000 (17:48 +0300)
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@intel.com>

src/drivers/driver_nl80211.c

index f29c640c99e0f28143d4c77d2267fabdd0a8432c..608e96517f1446718b6bf1dc332d0168dc4b8ce2 100644 (file)
@@ -140,17 +140,26 @@ static void nl_destroy_handles(struct nl_handle **handle)
 }
 
 
+#if __WORDSIZE == 64
+#define ELOOP_SOCKET_INVALID   (intptr_t) 0x8888888888888889ULL
+#else
+#define ELOOP_SOCKET_INVALID   (intptr_t) 0x88888889ULL
+#endif
+
 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 *) (((intptr_t) *handle) ^ ELOOP_SOCKET_INVALID);
 }
 
 
 static void nl80211_destroy_eloop_handle(struct nl_handle **handle)
 {
+       *handle = (void *) (((intptr_t) *handle) ^ ELOOP_SOCKET_INVALID);
        eloop_unregister_read_sock(nl_socket_get_fd(*handle));
        nl_destroy_handles(handle);
 }