summaryrefslogtreecommitdiff
path: root/trans/new-fifo.c
diff options
context:
space:
mode:
Diffstat (limited to 'trans/new-fifo.c')
-rw-r--r--trans/new-fifo.c62
1 files changed, 34 insertions, 28 deletions
diff --git a/trans/new-fifo.c b/trans/new-fifo.c
index 9266b1e5..203a7d4d 100644
--- a/trans/new-fifo.c
+++ b/trans/new-fifo.c
@@ -245,16 +245,18 @@ fifo_trans_open (struct fifo_trans *trans, int flags, void **hook)
mutex_lock (&trans->active_fifo_lock);
/* Wait until the active fifo has changed so that CONDITION is true. */
-#define WAIT(condition, noblock_err) \
- while (!err && !(condition)) \
- if (flags & O_NONBLOCK) \
- { \
- err = noblock_err; \
- break; \
- } \
- else if (hurd_condition_wait (&trans->active_fifo_changed, \
- &trans->active_fifo_lock)) \
- err = EINTR;
+#define WAIT(condition, noblock_err) \
+ while (!err && !(condition)) \
+ { \
+ if (flags & O_NONBLOCK) \
+ { \
+ err = noblock_err; \
+ break; \
+ } \
+ else if (hurd_condition_wait (&trans->active_fifo_changed, \
+ &trans->active_fifo_lock)) \
+ err = EINTR; \
+ }
if (flags & O_READ)
/* When opening for read, what we do depends on what mode this server
@@ -600,26 +602,30 @@ trivfs_S_io_select (struct trivfs_protid *cred,
pipe = cred->po->hook;
if (*select_type & SELECT_READ)
- if (cred->po->openmodes & O_READ)
- {
- mutex_lock (&pipe->lock);
- if (pipe_wait_readable (pipe, 1, 1) != EWOULDBLOCK)
- ready |= SELECT_READ; /* Data immediately readable (or error). */
- mutex_unlock (&pipe->lock);
- }
- else
- ready |= SELECT_READ; /* Error immediately available... */
+ {
+ if (cred->po->openmodes & O_READ)
+ {
+ mutex_lock (&pipe->lock);
+ if (pipe_wait_readable (pipe, 1, 1) != EWOULDBLOCK)
+ ready |= SELECT_READ; /* Data immediately readable (or error). */
+ mutex_unlock (&pipe->lock);
+ }
+ else
+ ready |= SELECT_READ; /* Error immediately available... */
+ }
if (*select_type & SELECT_WRITE)
- if (cred->po->openmodes & O_WRITE)
- {
- mutex_lock (&pipe->lock);
- if (pipe_wait_writable (pipe, 1) != EWOULDBLOCK)
- ready |= SELECT_WRITE; /* Data immediately writable (or error). */
- mutex_unlock (&pipe->lock);
- }
- else
- ready |= SELECT_WRITE; /* Error immediately available... */
+ {
+ if (cred->po->openmodes & O_WRITE)
+ {
+ mutex_lock (&pipe->lock);
+ if (pipe_wait_writable (pipe, 1) != EWOULDBLOCK)
+ ready |= SELECT_WRITE; /* Data immediately writable (or error). */
+ mutex_unlock (&pipe->lock);
+ }
+ else
+ ready |= SELECT_WRITE; /* Error immediately available... */
+ }
if (ready)
*select_type = ready;