diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2009-02-04 20:35:15 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2009-02-04 20:35:15 +0000 |
commit | 751b5132bb874db9601b5e853ac78ff29a04c113 (patch) | |
tree | 0ef4b3d6bdf7c751c265d0a271d12d74eb8a8710 /usr.bin/aucat/aucat.c | |
parent | ee4dbb556fd6b40c4aba4483d9401e7ebaf7bf2c (diff) |
if there are too many connections, stop acceping new ones rather
than exit()ing with ``too many open files'' fatal error
Diffstat (limited to 'usr.bin/aucat/aucat.c')
-rw-r--r-- | usr.bin/aucat/aucat.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c index 5ae6ea236bb..21947cd89b9 100644 --- a/usr.bin/aucat/aucat.c +++ b/usr.bin/aucat/aucat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aucat.c,v 1.56 2009/02/04 08:00:33 ratchov Exp $ */ +/* $OpenBSD: aucat.c,v 1.57 2009/02/04 20:35:14 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -267,6 +267,11 @@ newinput(struct farg *fa) * XXX : we should round rate, right ? */ f = wav_new_in(&wav_ops, fd, fa->name, &fa->ipar, fa->hdr); + if (f == NULL) { + if (fd != STDIN_FILENO) + close(fd); + return; + } nfr = dev_bufsz * fa->ipar.rate / dev_rate; buf = abuf_new(nfr, &fa->ipar); proc = rpipe_new((struct file *)f); @@ -304,6 +309,11 @@ newoutput(struct farg *fa) * XXX : we should round rate, right ? */ f = wav_new_out(&wav_ops, fd, fa->name, &fa->opar, fa->hdr); + if (f == NULL) { + if (fd != STDOUT_FILENO) + close(fd); + return; + } nfr = dev_bufsz * fa->opar.rate / dev_rate; proc = wpipe_new((struct file *)f); buf = abuf_new(nfr, &fa->opar); |