(Is the title better?)
On Fri, 2012-11-23 at 10:19 +0100, Samuel Thibault wrote:
> Svante Signell, le Fri 23 Nov 2012 08:00:26 +0100, a écrit :
> AIU hurdselect.c, it shouldn't change it too much:
...
> I.e. it forces the fd as readable, writable, and exception, which
> doesn't seem a bad thing to me.
Select case would be OK then without modifications. Only changes for
poll are needed.
Updated patch attached.
--- a/pflocal_io.c 2012-11-06 18:00:09.000000000 +0100
+++ b/pflocal/io.c 2012-11-23 12:53:16.000000000 +0100
@@ -217,6 +217,7 @@
{
int valid;
int ready = 0;
+ error_t err;
struct pipe *read_pipe = sock->read_pipe;
struct pipe *write_pipe = sock->write_pipe;
@@ -231,16 +232,22 @@
if (valid & SELECT_READ)
{
pipe_acquire_reader (read_pipe);
- if (pipe_wait_readable (read_pipe, 1, 1) != EWOULDBLOCK)
+ err = pipe_wait_readable (read_pipe, 1, 1);
+ if (err != EWOULDBLOCK)
ready |= SELECT_READ; /* Data immediately readable (or error). */
mutex_unlock (&read_pipe->lock);
+ if ((err != 0) && (err != EWOULDBLOCK))
+ return err;
}
if (valid & SELECT_WRITE)
{
pipe_acquire_writer (write_pipe);
- if (pipe_wait_writable (write_pipe, 1) != EWOULDBLOCK)
+ err = pipe_wait_writable (write_pipe, 1);
+ if (err != EWOULDBLOCK)
ready |= SELECT_WRITE; /* Data immediately writable (or error). */
mutex_unlock (&write_pipe->lock);
+ if ((err != 0) && (err != EWOULDBLOCK))
+ return err;
}
mutex_unlock (&sock->lock);
@@ -253,6 +260,8 @@
{
ports_interrupt_self_on_port_death (user, reply);
err = pipe_pair_select (read_pipe, write_pipe, select_type, 1);
+ if ((err != 0) && (err != EWOULDBLOCK) && (err != EINTR))
+ return err;
}
if (valid & SELECT_READ)