summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2020-04-15 14:26:40 +0000
committerratchov <ratchov@openbsd.org>2020-04-15 14:26:40 +0000
commitb3d2daecc17c6d96cd06b89186298c652f63cde9 (patch)
treec0ec7e0813fa7a37103669f58b54c215ad3143d7
parentDon't forget to notify clients when a control is removed (diff)
downloadwireguard-openbsd-b3d2daecc17c6d96cd06b89186298c652f63cde9.tar.xz
wireguard-openbsd-b3d2daecc17c6d96cd06b89186298c652f63cde9.zip
When device is (re-)opened, call dev_ctlsync() if there's no control device
In the dev_reopen() case the controls of the old device are removed, but if the new device has no controls, we still need to call dev_ctlsync() so that clients are notified about the removal of the old controls.
-rw-r--r--usr.bin/sndiod/dev_sioctl.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/usr.bin/sndiod/dev_sioctl.c b/usr.bin/sndiod/dev_sioctl.c
index e0c56db97cb..39e7180c762 100644
--- a/usr.bin/sndiod/dev_sioctl.c
+++ b/usr.bin/sndiod/dev_sioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev_sioctl.c,v 1.2 2020/03/08 14:52:20 ratchov Exp $ */
+/* $OpenBSD: dev_sioctl.c,v 1.3 2020/04/15 14:26:40 ratchov Exp $ */
/*
* Copyright (c) 2014-2020 Alexandre Ratchov <alex@caoua.org>
*
@@ -115,8 +115,16 @@ dev_sioctl_onval(void *arg, unsigned int addr, unsigned int val)
void
dev_sioctl_open(struct dev *d)
{
- if (d->sioctl.hdl == NULL)
+ if (d->sioctl.hdl == NULL) {
+ /*
+ * At this point there are clients, for instance if we're
+ * called by dev_reopen() but the control device couldn't
+ * be opened. In this case controls have changed (thoseof
+ * old device are just removed) so we need to notify clients.
+ */
+ dev_ctlsync(d);
return;
+ }
sioctl_ondesc(d->sioctl.hdl, dev_sioctl_ondesc, d);
sioctl_onval(d->sioctl.hdl, dev_sioctl_onval, d);
d->sioctl.file = file_new(&dev_sioctl_ops, d, "mix",