summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2009-08-28 06:30:17 +0000
committerratchov <ratchov@openbsd.org>2009-08-28 06:30:17 +0000
commitf9f1ab1e0401c80495e6089392ae2a914d60687f (patch)
treee94894ca3a7fd41a0fc40331c154bccfff04226e
parentkva_guardpages: make guard pages separate map entries (diff)
downloadwireguard-openbsd-f9f1ab1e0401c80495e6089392ae2a914d60687f.tar.xz
wireguard-openbsd-f9f1ab1e0401c80495e6089392ae2a914d60687f.zip
top device before closing it. It's necessary to ensure that if we
are using another instance of aucat as device, the server closes the connection before we open a new one.
-rw-r--r--usr.bin/aucat/safile.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.bin/aucat/safile.c b/usr.bin/aucat/safile.c
index a8cd4b8dd23..41438d9e240 100644
--- a/usr.bin/aucat/safile.c
+++ b/usr.bin/aucat/safile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: safile.c,v 1.14 2009/07/25 10:52:19 ratchov Exp $ */
+/* $OpenBSD: safile.c,v 1.15 2009/08/28 06:30:17 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -34,6 +34,7 @@
struct safile {
struct file file;
struct sio_hdl *hdl;
+ int started;
#ifdef DEBUG
struct timeval itv, otv;
#endif
@@ -150,6 +151,7 @@ safile_new(struct fileops *ops, char *path,
if (f == NULL)
goto bad_close;
f->hdl = hdl;
+ f->started = 0;
sio_onmove(f->hdl, safile_cb, f);
return f;
bad_close:
@@ -167,6 +169,7 @@ safile_start(struct file *file)
file_close(file);
return;
}
+ f->started = 1;
DPRINTF("safile_start: play/rec started\n");
}
@@ -180,6 +183,7 @@ safile_stop(struct file *file)
file_close(file);
return;
}
+ f->started = 0;
DPRINTF("safile_stop: play/rec stopped\n");
}
@@ -281,5 +285,9 @@ safile_revents(struct file *file, struct pollfd *pfd)
void
safile_close(struct file *file)
{
+ struct safile *f = (struct safile *)file;
+
+ if (f->started)
+ safile_stop(&f->file);
return sio_close(((struct safile *)file)->hdl);
}