summaryrefslogtreecommitdiff
path: root/usr.bin/aucat
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/aucat')
-rw-r--r--usr.bin/aucat/aproc.c34
-rw-r--r--usr.bin/aucat/aproc.h3
2 files changed, 19 insertions, 18 deletions
diff --git a/usr.bin/aucat/aproc.c b/usr.bin/aucat/aproc.c
index b7f8853d17f..fd5bf6c46f5 100644
--- a/usr.bin/aucat/aproc.c
+++ b/usr.bin/aucat/aproc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aproc.c,v 1.34 2009/09/27 11:51:20 ratchov Exp $ */
+/* $OpenBSD: aproc.c,v 1.35 2009/10/06 18:06:55 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -58,6 +58,7 @@ aproc_new(struct aproc_ops *ops, char *name)
p->name = name;
p->ops = ops;
p->refs = 0;
+ p->zomb = 0;
return p;
}
@@ -66,24 +67,23 @@ aproc_del(struct aproc *p)
{
struct abuf *i;
- /*
- * XXX: souldn't call ops->done() and friends twice
- * use a ``zomb'' flag or whatever
- */
-
- if (p->ops->done) {
- p->ops->done(p);
- }
- while (!LIST_EMPTY(&p->ibuflist)) {
- i = LIST_FIRST(&p->ibuflist);
- abuf_hup(i);
- }
- while (!LIST_EMPTY(&p->obuflist)) {
- i = LIST_FIRST(&p->obuflist);
- abuf_eof(i);
+ if (!p->zomb) {
+ if (p->ops->done) {
+ p->ops->done(p);
+ }
+ while (!LIST_EMPTY(&p->ibuflist)) {
+ i = LIST_FIRST(&p->ibuflist);
+ abuf_hup(i);
+ }
+ while (!LIST_EMPTY(&p->obuflist)) {
+ i = LIST_FIRST(&p->obuflist);
+ abuf_eof(i);
+ }
+ p->zomb = 1;
}
- if (p->refs > 0)
+ if (p->refs > 0) {
return;
+ }
free(p);
}
diff --git a/usr.bin/aucat/aproc.h b/usr.bin/aucat/aproc.h
index d139ffc7003..fd448b69cb6 100644
--- a/usr.bin/aucat/aproc.h
+++ b/usr.bin/aucat/aproc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: aproc.h,v 1.23 2009/09/27 11:51:20 ratchov Exp $ */
+/* $OpenBSD: aproc.h,v 1.24 2009/10/06 18:06:55 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -123,6 +123,7 @@ struct aproc {
LIST_HEAD(, abuf) ibuflist; /* list of inputs */
LIST_HEAD(, abuf) obuflist; /* list of outputs */
unsigned refs; /* extern references */
+ unsigned zomb; /* destroyed but not freed */
union { /* follow type-specific data */
struct { /* file/device io */
struct file *file; /* file to read/write */