summaryrefslogtreecommitdiff
path: root/pflocal
diff options
context:
space:
mode:
Diffstat (limited to 'pflocal')
-rw-r--r--pflocal/io.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/pflocal/io.c b/pflocal/io.c
index f67052f3..2301611e 100644
--- a/pflocal/io.c
+++ b/pflocal/io.c
@@ -231,15 +231,24 @@ S_io_select (struct sock_user *user,
if (valid & SELECT_READ)
{
pipe_acquire_reader (read_pipe);
- if (pipe_wait_readable (read_pipe, 1, 1) != EWOULDBLOCK)
- ready |= SELECT_READ; /* Data immediately readable (or error). */
+ err = pipe_wait_readable (read_pipe, 1, 1);
+ if (err == EWOULDBLOCK)
+ err = 0; /* Not readable, actually not an error. */
+ else
+ ready |= SELECT_READ; /* Data immediately readable (or error). */
pthread_mutex_unlock (&read_pipe->lock);
+ if (err)
+ /* Prevent write test from overwriting err. */
+ valid &= ~SELECT_WRITE;
}
if (valid & SELECT_WRITE)
{
pipe_acquire_writer (write_pipe);
- if (pipe_wait_writable (write_pipe, 1) != EWOULDBLOCK)
- ready |= SELECT_WRITE; /* Data immediately writable (or error). */
+ err = pipe_wait_writable (write_pipe, 1);
+ if (err == EWOULDBLOCK)
+ err = 0; /* Not writable, actually not an error. */
+ else
+ ready |= SELECT_WRITE; /* Data immediately writable (or error). */
pthread_mutex_unlock (&write_pipe->lock);
}