diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2020-04-15 14:26:41 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2020-04-15 14:26:41 +0000 |
commit | 12d6e9e4e1fcdcc08aa8834d62fa0bdc3de47e29 (patch) | |
tree | d93f859c85157bd81d5d92d641882450271b8978 /usr.bin/sndiod | |
parent | dd10093abec808e5d6a20be4194a27aac6030d2d (diff) |
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.
Diffstat (limited to 'usr.bin/sndiod')
-rw-r--r-- | usr.bin/sndiod/dev_sioctl.c | 12 |
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", |