From patchwork Sat Oct 26 10:23:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 286273 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 52FEE2C00CC for ; Sat, 26 Oct 2013 21:24:49 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 689319D1E6; Sat, 26 Oct 2013 06:24:44 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 66Sc5q+qJu1X; Sat, 26 Oct 2013 06:24:44 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 90BFF9CDCC; Sat, 26 Oct 2013 06:24:24 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 13E749CDCC for ; Sat, 26 Oct 2013 06:24:24 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8r08GmE7a4OM for ; Sat, 26 Oct 2013 06:24:19 -0400 (EDT) Received: from sipsolutions.net (s3.sipsolutions.net [144.76.43.152]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id D9D1D9C1CD for ; Sat, 26 Oct 2013 06:24:14 -0400 (EDT) Received: by sipsolutions.net with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Va12T-0006zw-Gr; Sat, 26 Oct 2013 12:24:13 +0200 From: Johannes Berg To: hostap@lists.shmoo.com Subject: [PATCH 3/3] nl80211: make eloop sockets non-blocking Date: Sat, 26 Oct 2013 12:23:52 +0200 Message-Id: <1382783032-26302-3-git-send-email-johannes@sipsolutions.net> X-Mailer: git-send-email 1.8.4.rc3 In-Reply-To: <1382783032-26302-1-git-send-email-johannes@sipsolutions.net> References: <1382783032-26302-1-git-send-email-johannes@sipsolutions.net> Cc: Johannes Berg X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com From: Johannes Berg 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 --- 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 +#else +#define ELOOP_SOCKET_INVALID 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 *)(((unsigned long)*handle) ^ ELOOP_SOCKET_INVALID); } static void nl80211_destroy_eloop_handle(struct nl_handle **handle) { + *handle = (void *)(((unsigned long)*handle) ^ ELOOP_SOCKET_INVALID); eloop_unregister_read_sock(nl_socket_get_fd(*handle)); nl_destroy_handles(handle); }