* fhandler.cc (fhandler_base::read): Remove unused signal state tweaks.

* fhandler.h (fhandler_pipe::create_selectable): Declare.
(fhandler_fifo::close_one_end): Declare.
* fhandler_fifo.cc (fhandler_fifo::close_one_end): Define.
(fhandler_fifo::open_not_mine): Use close_one_end to close appropriate end of
pipe.
* pinfo.cc (_pinfo::commune_recv): Ditto.
* pipe.cc (fhandler_pipe::create_selectable): Rename from
create_selectable_pipe.  Reorganize.
(fhandler_pipe::create): Use create_selectable.
This commit is contained in:
Christopher Faylor
2005-04-22 13:58:09 +00:00
parent b13aa00489
commit fb201f9270
7 changed files with 76 additions and 79 deletions

View File

@ -67,14 +67,30 @@ fhandler_fifo::close ()
}
#define DUMMY_O_RDONLY 4
void
fhandler_fifo::close_one_end ()
{
int testflags = (get_flags () & (O_RDWR | O_WRONLY | O_APPEND)) ?: DUMMY_O_RDONLY;
static int flagtypes[] = {DUMMY_O_RDONLY | O_RDWR, O_WRONLY | O_APPEND | O_RDWR};
HANDLE *handles[2] = {&(get_handle ()), &(get_output_handle ())};
for (int i = 0; i < 2; i++)
if (!(testflags & flagtypes[i]))
{
CloseHandle (*handles[i]);
*handles[i] = NULL;
}
else if (i == 0 && !read_state)
{
create_read_state (2);
need_fork_fixup (true);
}
}
int
fhandler_fifo::open_not_mine (int flags)
{
winpids pids;
static int flagtypes[] = {DUMMY_O_RDONLY | O_RDWR, O_WRONLY | O_APPEND | O_RDWR};
HANDLE *usehandles[2] = {&(get_handle ()), &(get_output_handle ())};
int res = 0;
int testflags = (flags & (O_RDWR | O_WRONLY | O_APPEND)) ?: DUMMY_O_RDONLY;
for (unsigned i = 0; i < pids.npids; i++)
{
@ -109,22 +125,11 @@ fhandler_fifo::open_not_mine (int flags)
}
}
for (int i = 0; i < 2; i++)
if (!(testflags & flagtypes[i]))
CloseHandle (r.handles[i]);
else
{
*usehandles[i] = r.handles[i];
if (i == 0)
{
read_state = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
need_fork_fixup (true);
}
}
res = 1;
set_io_handle (r.handles[0]);
set_output_handle (r.handles[1]);
set_flags (flags);
close_one_end ();
res = 1;
goto out;
}