summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2009-08-01 08:32:24 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2009-08-01 08:32:24 +0000
commit1caac63ad90a715b707900e2a89a47b392d12335 (patch)
treef9fb79cb654c56760de71e372b4045bc31382fc9
parentba4300df2c7a68b9a7146f5d3d69941a2157d341 (diff)
honor non-blocking flag in mio_open_rmidi(), fixes programs
eating 100% CPU while trying to use blocking i/o. ok jakemsr
-rw-r--r--lib/libsndio/mio_rmidi.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libsndio/mio_rmidi.c b/lib/libsndio/mio_rmidi.c
index 25bd3506e51..e1128f9c39a 100644
--- a/lib/libsndio/mio_rmidi.c
+++ b/lib/libsndio/mio_rmidi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mio_rmidi.c,v 1.4 2009/07/26 12:40:45 ratchov Exp $ */
+/* $OpenBSD: mio_rmidi.c,v 1.5 2009/08/01 08:32:23 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -67,8 +67,9 @@ mio_open_rmidi(const char *str, unsigned mode, int nbio)
flags = O_RDWR;
else
flags = (mode & MIO_OUT) ? O_WRONLY : O_RDONLY;
-
- while ((fd = open(path, flags | O_NONBLOCK)) < 0) {
+ if (nbio)
+ flags |= O_NONBLOCK;
+ while ((fd = open(path, flags)) < 0) {
if (errno == EINTR)
continue;
DPERROR(path);