Preliminary change to make fifos/pipes interruptible and fifos reliable.
* dtable.cc (dtable::find_fifo): Eliminate definition. * dtable.h (dtable::find_fifo): Ditto for declaration. * fhandler.cc (fhandler_base::raw_read): Remove pipe-specific stuff. (fhandler_base::fhandler_base): Ditto. (fhandler_base::close): Handle overlapped I/O structure if appropriate. (fhandler_base::dup): Ditto. (fhandler_base::fork_fixup): Ditto. (fhandler_base::setup_overlapped): Define new function. (fhandler_base::destroy_overlapped): Ditto. (fhandler_base::wait_overlapped): Ditto. (fhandler_base::read_overlapped): Ditto. (fhandler_base::write_overlapped): Ditto. * fhandler.h (fhandler_base::get_overlapped): Declare new function. (fhandler_base::setup_overlapped): Ditto. (fhandler_base::destroy_overlapped): Ditto. (fhandler_base::wait_overlapped): Ditto. (fhandler_base::read_overlapped): Ditto. (fhandler_base::write_overlapped): Ditto. (fhandler_base::get_guard): Eliminate. (fhandler_pipe::*): Rework to eliminate most Win9x related cruft, removing many variables and defining a new overlapped capability. (fhandler_fifo::*): Ditto. (fifo_state): Declare new enum. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove old Win9x stuff. Initialize overlapped handle to NULL. (fhandler_fifo::set_use): Eliminate. (fhandler_fifo::open_nonserver): Define. (fhandler_fifo::open): Rework to use named pipes and overlapped I/O. (fhandler_fifo::wait): Define new function to wait for named pipe connection. (fhandler_fifo::read): Rework to use wait() and new overlapped I/O functionality. (fhandler_fifo::write): Ditto. (fhandler_fifo::dup): Eliminate. * pinfo.cc (commune_process): Remove fifo handling. (_pinfo::commune_request): Ditto. * pinfo.h (picom): Ditto. * pipe.cc (fhandler_pipe::fhandler_pipe): Remove Win9x stuff. Initialize overlapped handle to NULL. (fhandler_pipe::open): Eliminate Win9x stuff. (fhandler_pipe::set_close_on_exec): Eliminate. (read_pipe): Eliminate. (fhandler_pipe::close): Ditto. (fhandler_pipe::fixup_after_exec): Ditto. (fhandler_pipe::fixup_in_child): Ditto. (fhandler_pipe::read): Rework to use overlapped I/O. (fhandler_pipe::write): New function using overlapped I/O. (fhandler_pipe::dup): Rework to eliminate Win9x stuff. (fhandler_pipe::create_selectable): Rework to eliminate Win9x and use overlapped I/O. * select.cc (peek_pipe): Rework to eliminate Win9x stuff and use overlapped I/O. (fhandler_base::ready_for_read): Ditto.
This commit is contained in:
@@ -517,31 +517,6 @@ commune_process (void *arg)
|
||||
sigproc_printf ("WriteFile fd failed, %E");
|
||||
break;
|
||||
}
|
||||
case PICOM_FIFO:
|
||||
{
|
||||
sigproc_printf ("processing PICOM_FIFO for %s", si._si_commune._si_str);
|
||||
fhandler_fifo *fh = cygheap->fdtab.find_fifo (si._si_commune._si_str);
|
||||
HANDLE it[2];
|
||||
if (fh == NULL)
|
||||
it[0] = it[1] = NULL;
|
||||
else
|
||||
{
|
||||
it[0] = fh->get_handle ();
|
||||
it[1] = fh->get_output_handle ();
|
||||
}
|
||||
|
||||
debug_printf ("fifo %sfound %p, %p", fh ? "" : "not ", it[0], it[1]);
|
||||
if (!WriteFile (tothem, it, sizeof (it), &nr, NULL))
|
||||
{
|
||||
/*__seterrno ();*/ // this is run from the signal thread, so don't set errno
|
||||
sigproc_printf ("WriteFile read handle failed, %E");
|
||||
}
|
||||
WaitForSingleObject (process_sync, INFINITE);
|
||||
process_sync = NULL;
|
||||
if (fh)
|
||||
fh->close_one_end ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (process_sync)
|
||||
{
|
||||
@@ -591,8 +566,6 @@ _pinfo::commune_request (__uint32_t code, ...)
|
||||
si._si_commune._si_fd = va_arg (args, int);
|
||||
break;
|
||||
|
||||
case PICOM_FIFO:
|
||||
si._si_commune._si_str = va_arg (args, char *);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -642,26 +615,6 @@ _pinfo::commune_request (__uint32_t code, ...)
|
||||
res.n = p - res.s;
|
||||
}
|
||||
break;
|
||||
case PICOM_FIFO:
|
||||
{
|
||||
lock_process now ();
|
||||
DWORD x = ReadFile (fromthem, res.handles, sizeof (res.handles), &nr, NULL);
|
||||
if (!x || nr != sizeof (res.handles))
|
||||
{
|
||||
__seterrno ();
|
||||
goto err;
|
||||
}
|
||||
for (int i = 0; i < 2; i++)
|
||||
if (!DuplicateHandle (hp, res.handles[i], hMainProc, &res.handles[i],
|
||||
0, false, DUPLICATE_SAME_ACCESS))
|
||||
{
|
||||
if (i)
|
||||
CloseHandle (res.handles[0]);
|
||||
res.handles[0] = res.handles[1] = NULL; /* FIXME: possibly left a handle open in child? */
|
||||
goto err;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
goto out;
|
||||
|
||||
|
Reference in New Issue
Block a user