* fhandler.h (class fhandler_pipe): Remove members writepipe_exists,

orig_pid and id.  Make hit_eof inline.
	* fhandler_fifo.cc (fhandler_fifo::open): Drop handling of
	writepipe_exists, orig_pid and id.
	* pipe.cc: Ditto throughout.
	(pipecount): Remove.
	(pipeid_fmt): Remove.
	(fhandler_pipe::hit_eof): Simplify.  Move to fhandler.h.
	(fhandler_pipe::dup): Drop leave label.
	(fhandler_pipe::create): Drop has_unreliable_pipes case.
	* wincap.cc: Remove has_unreliable_pipes throughout.
	* wincap.h: Ditto.
This commit is contained in:
Corinna Vinschen 2007-02-23 14:47:45 +00:00
parent 296a8a6369
commit 9fa43ff6c6
6 changed files with 20 additions and 84 deletions

View File

@ -1,3 +1,18 @@
2007-02-23 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_pipe): Remove members writepipe_exists,
orig_pid and id. Make hit_eof inline.
* fhandler_fifo.cc (fhandler_fifo::open): Drop handling of
writepipe_exists, orig_pid and id.
* pipe.cc: Ditto throughout.
(pipecount): Remove.
(pipeid_fmt): Remove.
(fhandler_pipe::hit_eof): Simplify. Move to fhandler.h.
(fhandler_pipe::dup): Drop leave label.
(fhandler_pipe::create): Drop has_unreliable_pipes case.
* wincap.cc: Remove has_unreliable_pipes throughout.
* wincap.h: Ditto.
2007-02-23 Corinna Vinschen <corinna@vinschen.de>
* devices.in: Change native device name to native NT device name for

View File

@ -518,9 +518,6 @@ class fhandler_pipe: public fhandler_base
protected:
HANDLE guard;
bool broken_pipe;
HANDLE writepipe_exists;
DWORD orig_pid;
unsigned id;
private:
pid_t popen_pid;
public:
@ -548,7 +545,7 @@ public:
void fixup_in_child ();
virtual void fixup_after_fork (HANDLE);
void fixup_after_exec ();
bool hit_eof ();
bool hit_eof () {return broken_pipe;}
void set_eof () {broken_pipe = true;}
HANDLE get_guard () const {return guard;}
int ready_for_read (int fd, DWORD howlong);

View File

@ -203,9 +203,6 @@ fhandler_fifo::open (int flags, mode_t)
set_output_handle (fhs[1]->get_handle ());
guard = fhs[0]->guard;
read_state = fhs[0]->read_state;
writepipe_exists = fhs[1]->writepipe_exists;
orig_pid = fhs[0]->orig_pid;
id = fhs[0]->id;
delete (fhs[0]);
delete (fhs[1]);
set_use (1);

View File

@ -1,7 +1,7 @@
/* pipe.cc: pipe for Cygwin.
Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Hat, Inc.
Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
2007 Hat, Inc.
This file is part of Cygwin.
@ -27,12 +27,8 @@ details. */
#include "cygthread.h"
#include "ntdll.h"
static unsigned pipecount;
static const NO_COPY char pipeid_fmt[] = "stupid_pipe.%u.%u";
fhandler_pipe::fhandler_pipe ()
: fhandler_base (), guard (NULL), broken_pipe (false), writepipe_exists (NULL),
orig_pid (0), id (0), popen_pid (0)
: fhandler_base (), guard (NULL), broken_pipe (false), popen_pid (0)
{
need_fork_fixup (true);
}
@ -111,15 +107,6 @@ fhandler_pipe::open (int flags, mode_t mode)
__seterrno ();
goto out;
}
if (!fh->writepipe_exists)
/* nothing to do */;
else if (!DuplicateHandle (proc, fh->writepipe_exists,
hMainProc, &writepipe_exists,
0, inh, DUPLICATE_SAME_ACCESS))
{
__seterrno ();
goto out;
}
if (fh->read_state)
create_read_state (2);
init (nio_hdl, fh->get_access (), mode & O_TEXT ?: O_BINARY);
@ -130,8 +117,6 @@ fhandler_pipe::open (int flags, mode_t mode)
CloseHandle (proc);
return 1;
out:
if (writepipe_exists)
CloseHandle (writepipe_exists);
if (guard)
CloseHandle (guard);
if (nio_hdl)
@ -174,8 +159,6 @@ fhandler_pipe::set_close_on_exec (bool val)
set_no_inheritance (guard, val);
ModifyHandle (guard, !val);
}
if (writepipe_exists)
set_no_inheritance (writepipe_exists, val);
}
char *
@ -220,8 +203,6 @@ fhandler_pipe::close ()
{
if (guard)
ForceCloseHandle (guard);
if (writepipe_exists)
CloseHandle (writepipe_exists);
#ifndef NEWVFORK
if (read_state)
#else
@ -234,22 +215,6 @@ fhandler_pipe::close ()
return fhandler_base::close ();
}
bool
fhandler_pipe::hit_eof ()
{
char buf[80];
HANDLE ev;
if (broken_pipe)
return 1;
if (!orig_pid)
return false;
__small_sprintf (buf, pipeid_fmt, orig_pid, id);
if ((ev = OpenEvent (EVENT_ALL_ACCESS, FALSE, buf)))
CloseHandle (ev);
debug_printf ("%s %p", buf, ev);
return ev == NULL;
}
void
fhandler_pipe::fixup_in_child ()
{
@ -270,8 +235,6 @@ fhandler_pipe::fixup_after_fork (HANDLE parent)
fhandler_base::fixup_after_fork (parent);
if (guard && fork_fixup (parent, guard, "guard"))
ProtectHandle (guard);
if (writepipe_exists)
fork_fixup (parent, writepipe_exists, "writepipe_exists");
fixup_in_child ();
}
@ -281,7 +244,7 @@ fhandler_pipe::dup (fhandler_base *child)
int res = -1;
fhandler_pipe *ftp = (fhandler_pipe *) child;
ftp->set_popen_pid (0);
ftp->guard = ftp->writepipe_exists = ftp->read_state = NULL;
ftp->guard = ftp->read_state = NULL;
if (get_handle () && fhandler_base::dup (child))
goto err;
@ -297,16 +260,6 @@ fhandler_pipe::dup (fhandler_base *child)
goto err;
}
if (!writepipe_exists)
/* nothing to do */;
else if (!DuplicateHandle (hMainProc, writepipe_exists, hMainProc,
&ftp->writepipe_exists, 0, true,
DUPLICATE_SAME_ACCESS))
{
debug_printf ("couldn't duplicate writepipe_exists %p, %E", writepipe_exists);
goto err;
}
if (!read_state)
/* nothing to do */;
else if (DuplicateHandle (hMainProc, read_state, hMainProc,
@ -325,18 +278,10 @@ fhandler_pipe::dup (fhandler_base *child)
err:
if (ftp->guard)
ForceCloseHandle1 (ftp->guard, guard);
if (ftp->writepipe_exists)
CloseHandle (ftp->writepipe_exists);
if (ftp->read_state)
ForceCloseHandle1 (ftp->read_state, read_state);
goto leave;
out:
ftp->id = id;
ftp->orig_pid = orig_pid;
VerifyHandle (ftp->writepipe_exists);
leave:
debug_printf ("res %d", res);
return res;
}
@ -473,15 +418,6 @@ fhandler_pipe::create (fhandler_pipe *fhs[2], unsigned psize, int mode, bool fif
res = 0;
fhs[0]->create_guard (sa);
if (wincap.has_unreliable_pipes ())
{
char buf[80];
int count = pipecount++; /* FIXME: Should this be InterlockedIncrement? */
__small_sprintf (buf, pipeid_fmt, myself->pid, count);
fhs[1]->writepipe_exists = CreateEvent (sa, TRUE, FALSE, buf);
fhs[0]->orig_pid = myself->pid;
fhs[0]->id = count;
}
}
syscall_printf ("%d = pipe ([%p, %p], %d, %p)", res, fhs[0], fhs[1], psize, mode);

View File

@ -20,7 +20,6 @@ static NO_COPY wincaps wincap_unknown = {
has_security_descriptor_control:false,
has_ip_helper_lib:false,
has_physical_mem_access:true,
has_unreliable_pipes:false,
has_process_io_counters:false,
has_terminal_services:false,
has_ioctl_storage_get_media_types_ex:false,
@ -48,7 +47,6 @@ static NO_COPY wincaps wincap_nt4 = {
has_security_descriptor_control:false,
has_ip_helper_lib:false,
has_physical_mem_access:true,
has_unreliable_pipes:false,
has_process_io_counters:false,
has_terminal_services:false,
has_ioctl_storage_get_media_types_ex:false,
@ -76,7 +74,6 @@ static NO_COPY wincaps wincap_nt4sp4 = {
has_security_descriptor_control:false,
has_ip_helper_lib:true,
has_physical_mem_access:true,
has_unreliable_pipes:false,
has_process_io_counters:false,
has_terminal_services:false,
has_ioctl_storage_get_media_types_ex:false,
@ -104,7 +101,6 @@ static NO_COPY wincaps wincap_2000 = {
has_security_descriptor_control:true,
has_ip_helper_lib:true,
has_physical_mem_access:true,
has_unreliable_pipes:false,
has_process_io_counters:true,
has_terminal_services:true,
has_ioctl_storage_get_media_types_ex:false,
@ -132,7 +128,6 @@ static NO_COPY wincaps wincap_xp = {
has_security_descriptor_control:true,
has_ip_helper_lib:true,
has_physical_mem_access:true,
has_unreliable_pipes:false,
has_process_io_counters:true,
has_terminal_services:true,
has_ioctl_storage_get_media_types_ex:true,
@ -160,7 +155,6 @@ static NO_COPY wincaps wincap_2003 = {
has_security_descriptor_control:true,
has_ip_helper_lib:true,
has_physical_mem_access:false,
has_unreliable_pipes:false,
has_process_io_counters:true,
has_terminal_services:true,
has_ioctl_storage_get_media_types_ex:true,
@ -188,7 +182,6 @@ static NO_COPY wincaps wincap_vista = {
has_security_descriptor_control:true,
has_ip_helper_lib:true,
has_physical_mem_access:false,
has_unreliable_pipes:false,
has_process_io_counters:true,
has_terminal_services:true,
has_ioctl_storage_get_media_types_ex:true,

View File

@ -20,7 +20,6 @@ struct wincaps
unsigned has_security_descriptor_control : 1;
unsigned has_ip_helper_lib : 1;
unsigned has_physical_mem_access : 1;
unsigned has_unreliable_pipes : 1;
unsigned has_process_io_counters : 1;
unsigned has_terminal_services : 1;
unsigned has_ioctl_storage_get_media_types_ex : 1;
@ -64,7 +63,6 @@ public:
bool IMPLEMENT (has_security_descriptor_control)
bool IMPLEMENT (has_ip_helper_lib)
bool IMPLEMENT (has_physical_mem_access)
bool IMPLEMENT (has_unreliable_pipes)
bool IMPLEMENT (has_process_io_counters)
bool IMPLEMENT (has_terminal_services)
bool IMPLEMENT (has_ioctl_storage_get_media_types_ex)