aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/ctrl_iface_unix.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2013-08-24 17:31:04 (GMT)
committerJouni Malinen <j@w1.fi>2013-08-24 17:31:04 (GMT)
commit8d6e0350726ea193711d189d6fbf7022a9e4b189 (patch)
tree707648ed73bfabc3945b19705b038e9ea20ce777 /wpa_supplicant/ctrl_iface_unix.c
parent3ed2814a1e6e3379c781e8fdd1a3fc7006ec6cf0 (diff)
downloadhostap-8d6e0350726ea193711d189d6fbf7022a9e4b189.zip
hostap-8d6e0350726ea193711d189d6fbf7022a9e4b189.tar.gz
hostap-8d6e0350726ea193711d189d6fbf7022a9e4b189.tar.bz2
Make global UNIX socket non-blocking for ctrl_iface
This keeps wpa_supplicant from hanging forever if the other end of the socket dies. This is similar to the earlier commit 4fdc8def8855ce9b90ffbbdc47152ce46ccdcb1e to make the global control interface befave in the same way. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/ctrl_iface_unix.c')
-rw-r--r--wpa_supplicant/ctrl_iface_unix.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/wpa_supplicant/ctrl_iface_unix.c b/wpa_supplicant/ctrl_iface_unix.c
index fc0d649..cd26eab 100644
--- a/wpa_supplicant/ctrl_iface_unix.c
+++ b/wpa_supplicant/ctrl_iface_unix.c
@@ -722,6 +722,7 @@ wpa_supplicant_global_ctrl_iface_init(struct wpa_global *global)
struct ctrl_iface_global_priv *priv;
struct sockaddr_un addr;
const char *ctrl = global->params.ctrl_interface;
+ int flags;
priv = os_zalloc(sizeof(*priv));
if (priv == NULL)
@@ -864,6 +865,20 @@ wpa_supplicant_global_ctrl_iface_init(struct wpa_global *global)
}
havesock:
+
+ /*
+ * Make socket non-blocking so that we don't hang forever if
+ * target dies unexpectedly.
+ */
+ flags = fcntl(priv->sock, F_GETFL);
+ if (flags >= 0) {
+ flags |= O_NONBLOCK;
+ if (fcntl(priv->sock, F_SETFL, flags) < 0) {
+ perror("fcntl(ctrl, O_NONBLOCK)");
+ /* Not fatal, continue on.*/
+ }
+ }
+
eloop_register_read_sock(priv->sock,
wpa_supplicant_global_ctrl_iface_receive,
global, priv);