diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2021-01-28 11:15:32 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2021-01-28 11:15:32 +0000 |
commit | 305dfd425594dfa4017b1fc81e45ad43a7fd2b08 (patch) | |
tree | eab5bfd53cbd8b697806973f049b98a11ed3117d /usr.bin/sndiod/dev.c | |
parent | 57f179855411f37933dd7da9f9471b04b23e0d87 (diff) |
Dont attempt to drain disconnected clients
Clients are always drained before they disconnect, so this change
affects programs that die unexpectedly or loose thier network
connection.
Besides the bad style, this change fixes a theoretical bug when the
disconnected client slot could be recycled and given to another client
while it's being drained
Diffstat (limited to 'usr.bin/sndiod/dev.c')
-rw-r--r-- | usr.bin/sndiod/dev.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c index e3ce842711d..06412ae6ade 100644 --- a/usr.bin/sndiod/dev.c +++ b/usr.bin/sndiod/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.81 2021/01/28 11:10:00 ratchov Exp $ */ +/* $OpenBSD: dev.c,v 1.82 2021/01/28 11:15:31 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -1972,9 +1972,8 @@ slot_del(struct slot *s) case SLOT_START: case SLOT_READY: case SLOT_RUN: - slot_stop(s); - /* PASSTHROUGH */ case SLOT_STOP: + slot_stop(s, 0); break; } dev_unref(s->dev); @@ -2195,7 +2194,7 @@ slot_detach(struct slot *s) * stop & detach if no data to drain. */ void -slot_stop(struct slot *s) +slot_stop(struct slot *s, int drain) { #ifdef DEBUG if (log_level >= 3) { @@ -2214,7 +2213,7 @@ slot_stop(struct slot *s) } if (s->pstate == SLOT_RUN) { - if (s->mode & MODE_PLAY) { + if ((s->mode & MODE_PLAY) && drain) { /* * Don't detach, dev_cycle() will do it for us * when the buffer is drained. @@ -2223,6 +2222,8 @@ slot_stop(struct slot *s) return; } slot_detach(s); + } else if (s->pstate == SLOT_STOP) { + slot_detach(s); } else { #ifdef DEBUG if (log_level >= 3) { |