summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2010-04-24 13:32:21 +0000
committerratchov <ratchov@openbsd.org>2010-04-24 13:32:21 +0000
commit74d128e9da9ff8e054682ac57cc600ceaf9db0e7 (patch)
treeee501f6ecbc3abae6fa89c461c81386d7ca587bc
parentFix breakage of dig's -p option introduced when support for (diff)
downloadwireguard-openbsd-74d128e9da9ff8e054682ac57cc600ceaf9db0e7.tar.xz
wireguard-openbsd-74d128e9da9ff8e054682ac57cc600ceaf9db0e7.zip
don't increment mixer's ``idle'' counter before truncating the
amount of samples to commit to ``maxwrite''. Overwise uncommitted samples are accounted as idle, in turn causing the device to be stopped too early, possibly truncating few blocks at the end of streams being drained. subtle bug spotted and analysed by Thomas Pfaff, thanks
-rw-r--r--usr.bin/aucat/aproc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/aucat/aproc.c b/usr.bin/aucat/aproc.c
index 74b9be95dc3..7fa0c61c6a1 100644
--- a/usr.bin/aucat/aproc.c
+++ b/usr.bin/aucat/aproc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aproc.c,v 1.54 2010/04/24 06:18:23 ratchov Exp $ */
+/* $OpenBSD: aproc.c,v 1.55 2010/04/24 13:32:21 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -854,6 +854,7 @@ mix_out(struct aproc *p, struct abuf *obuf)
maxwrite = p->u.mix.maxlat - p->u.mix.lat;
mix_bzero(obuf);
scount = 0;
+ /* XXX: can obuf->len be larger than obuf->w.mix.todo ? */
odone = obuf->len;
for (i = LIST_FIRST(&p->ins); i != NULL; i = inext) {
inext = LIST_NEXT(i, ient);
@@ -878,7 +879,6 @@ mix_out(struct aproc *p, struct abuf *obuf)
if (!(p->flags & APROC_DROP))
return 0;
odone = obuf->w.mix.todo;
- p->u.mix.idle += odone;
}
if (maxwrite > 0) {
if (odone > maxwrite)
@@ -893,6 +893,8 @@ mix_out(struct aproc *p, struct abuf *obuf)
if (APROC_OK(p->u.mix.mon))
mon_snoop(p->u.mix.mon, obuf, obuf->used - odone, odone);
}
+ if (LIST_EMPTY(&p->ins))
+ p->u.mix.idle += odone;
if (scount == 0)
return 0;
return 1;