summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2008-11-16 17:01:59 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2008-11-16 17:01:59 +0000
commit7e845d6f68f34df6287641928d5e8f60fcee674c (patch)
tree2ffd4e9c926f29e5f67fd23d01bf1fc0caf25b11 /usr.bin
parent1ceac89becb8b9bfe05eeeadda1ddb4f289cd2ed (diff)
in file_poll() the number of polled file structures is not equal to the
number of polled descriptors. Count the number of polled structrues to detect deadlocks rather than the number of descriptors, avoinding false positives.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/aucat/file.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/usr.bin/aucat/file.c b/usr.bin/aucat/file.c
index 8ce62b5bbeb..d2d008aa017 100644
--- a/usr.bin/aucat/file.c
+++ b/usr.bin/aucat/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.4 2008/10/26 08:49:44 ratchov Exp $ */
+/* $OpenBSD: file.c,v 1.5 2008/11/16 17:01:58 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -108,6 +108,9 @@ file_poll(void)
struct pollfd pfds[MAXFDS];
struct file *f, *fnext;
struct aproc *p;
+#ifdef DEBUG
+ unsigned nused;
+#endif
/*
* fill the pfds[] array with files that are blocked on reading
@@ -115,12 +118,19 @@ file_poll(void)
*/
DPRINTFN(4, "file_poll:");
nfds = 0;
+#ifdef DEBUG
+ nused = 0;
+#endif
LIST_FOREACH(f, &file_list, entry) {
events = 0;
if (f->rproc && !(f->state & FILE_ROK))
events |= POLLIN;
if (f->wproc && !(f->state & FILE_WOK))
events |= POLLOUT;
+#ifdef DEBUG
+ if (events)
+ nused++;
+#endif
DPRINTFN(4, " %s(%x)", f->name, events);
n = f->ops->pollfd(f, pfds + nfds, events);
if (n == 0) {
@@ -133,7 +143,7 @@ file_poll(void)
DPRINTFN(4, "\n");
#ifdef DEBUG
- if (nfds == 0 && !LIST_EMPTY(&file_list)) {
+ if (nused == 0 && !LIST_EMPTY(&file_list)) {
fprintf(stderr, "file_poll: deadlock\n");
abort();
}