* fhandler.h (fhandler_base::setup_overlapped): Delete virtual declaration.

(fhandler_base::destroy_overlapped): Ditto.
(fhandler_base_overlapped): Remove now-unneeded friend.
(fhandler_base_overlapped::setup_overlapped): Return int, remove parameter.
(fhandler_base_overlapped::get_overlapped): Return reference.
(fhandler_base_overlapped::fhandler_base_overlapped): Be more assertive about
zeroing everything.
(fhandler_base_overlapped::fixup_after_fork): Declare new function.
(fhandler_base_overlapped::fixup_after_exec): Ditto.
(fhandler_base_overlapped::dup): Ditto.
(fhandler_base_overlapped::close): Ditto.
* fhandler_fifo.cc (fhandler_fifo::dup): Call fhandler_base_overlapped::dup
rather than fhandler_base::dup.
* pipe.cc (fhandler_pipe::dup): Ditto.
(fhandler_pipe::init): Accommodate change in setup_overlapped arguments for
"opened_properly" case.
This commit is contained in:
Christopher Faylor 2010-04-02 18:55:02 +00:00
parent 60efdd0c4c
commit 5151c80c8a
5 changed files with 75 additions and 29 deletions

View File

@ -1,3 +1,24 @@
2010-04-02 Christopher Faylor <me+cygwin@cgf.cx>
* fhandler.h (fhandler_base::setup_overlapped): Delete virtual
declaration.
(fhandler_base::destroy_overlapped): Ditto.
(fhandler_base_overlapped): Remove now-unneeded friend.
(fhandler_base_overlapped::setup_overlapped): Return int, remove
parameter.
(fhandler_base_overlapped::get_overlapped): Return reference.
(fhandler_base_overlapped::fhandler_base_overlapped): Be more assertive
about zeroing everything.
(fhandler_base_overlapped::fixup_after_fork): Declare new function.
(fhandler_base_overlapped::fixup_after_exec): Ditto.
(fhandler_base_overlapped::dup): Ditto.
(fhandler_base_overlapped::close): Ditto.
* fhandler_fifo.cc (fhandler_fifo::dup): Call
fhandler_base_overlapped::dup rather than fhandler_base::dup.
* pipe.cc (fhandler_pipe::dup): Ditto.
(fhandler_pipe::init): Accommodate change in setup_overlapped arguments
for "opened_properly" case.
2010-04-02 Christopher Faylor <me+cygwin@cgf.cx>
* fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Properly initialize

View File

@ -1037,10 +1037,17 @@ fhandler_base::close ()
__seterrno ();
}
destroy_overlapped ();
return res;
}
int
fhandler_base_overlapped::close ()
{
destroy_overlapped ();
return fhandler_base::close ();
}
int
fhandler_base::ioctl (unsigned int cmd, void *buf)
{
@ -1162,10 +1169,17 @@ fhandler_base::dup (fhandler_base *child)
VerifyHandle (nh);
child->set_io_handle (nh);
}
child->setup_overlapped ();
return 0;
}
int
fhandler_base_overlapped::dup (fhandler_base *child)
{
int res = fhandler_base::dup (child) ||
((fhandler_base_overlapped *) child)->setup_overlapped ();
return res;
}
int fhandler_base::fcntl (int cmd, void *arg)
{
int res;
@ -1334,7 +1348,6 @@ fhandler_base::fork_fixup (HANDLE parent, HANDLE &h, const char *name)
VerifyHandle (h);
res = true;
}
setup_overlapped ();
return res;
}
@ -1353,20 +1366,31 @@ fhandler_base::fixup_after_fork (HANDLE parent)
debug_printf ("inheriting '%s' from parent", get_name ());
if (!nohandle ())
fork_fixup (parent, io_handle, "io_handle");
setup_overlapped ();
/* POSIX locks are not inherited across fork. */
if (unique_id)
del_my_locks (after_fork);
}
void
fhandler_base_overlapped::fixup_after_fork (HANDLE parent)
{
setup_overlapped ();
fhandler_base::fixup_after_fork (parent);
}
void
fhandler_base::fixup_after_exec ()
{
debug_printf ("here for '%s'", get_name ());
setup_overlapped ();
if (unique_id && close_on_exec ())
del_my_locks (after_exec);
}
void
fhandler_base_overlapped::fixup_after_exec ()
{
setup_overlapped ();
fhandler_base::fixup_after_exec ();
}
bool
fhandler_base::is_nonblocking ()
@ -1640,23 +1664,14 @@ fhandler_base::fpathconf (int v)
/* Overlapped I/O */
bool
fhandler_base_overlapped::setup_overlapped (bool doit)
int
fhandler_base_overlapped::setup_overlapped ()
{
OVERLAPPED *ov = get_overlapped_buffer ();
memset (ov, 0, sizeof (*ov));
bool res;
if (doit)
{
set_overlapped (ov);
res = !!(ov->hEvent = CreateEvent (&sec_none_nih, true, true, NULL));
}
else
{
set_overlapped (NULL);
res = false;
}
return res;
set_overlapped (ov);
ov->hEvent = CreateEvent (&sec_none_nih, true, true, NULL);
return ov->hEvent ? 0 : -1;
}
void
@ -1668,6 +1683,8 @@ fhandler_base_overlapped::destroy_overlapped ()
CloseHandle (ov->hEvent);
ov->hEvent = NULL;
}
io_pending = false;
get_overlapped () = NULL;
}
bool

View File

@ -386,8 +386,6 @@ class fhandler_base
bool issymlink () {return pc.issymlink ();}
bool device_access_denied (int) __attribute__ ((regparm (2)));
int fhaccess (int flags, bool) __attribute__ ((regparm (3)));
virtual void destroy_overlapped () __attribute__ ((regparm (1))) {}
virtual bool setup_overlapped () {return false;}
};
class fhandler_mailslot : public fhandler_base
@ -560,17 +558,24 @@ protected:
OVERLAPPED *overlapped;
public:
int wait_overlapped (bool, bool, DWORD *, DWORD = 0) __attribute__ ((regparm (3)));
bool setup_overlapped (bool doit = true) __attribute__ ((regparm (2)));
int setup_overlapped () __attribute__ ((regparm (1)));
void destroy_overlapped () __attribute__ ((regparm (1)));
void __stdcall read_overlapped (void *ptr, size_t& len) __attribute__ ((regparm (3)));
ssize_t __stdcall write_overlapped (const void *ptr, size_t len);
OVERLAPPED *get_overlapped () {return overlapped;}
OVERLAPPED *&get_overlapped () {return overlapped;}
OVERLAPPED *get_overlapped_buffer () {return &io_status;}
void set_overlapped (OVERLAPPED *ov) {overlapped = ov;}
fhandler_base_overlapped (): io_pending (false), overlapped (NULL) {}
fhandler_base_overlapped (): io_pending (false), overlapped (NULL)
{
memset (&io_status, 0, sizeof io_status);
}
bool has_ongoing_io ();
friend class select_pipe_info; /* FIXME: At least correct the naming
here */
void fixup_after_fork (HANDLE);
void fixup_after_exec ();
int close ();
int dup (fhandler_base *child);
};
class fhandler_pipe: public fhandler_base_overlapped

View File

@ -304,7 +304,7 @@ fhandler_fifo::close ()
int
fhandler_fifo::dup (fhandler_base *child)
{
int res = fhandler_base::dup (child);
int res = fhandler_base_overlapped::dup (child);
fhandler_fifo *fifo_child = (fhandler_fifo *) child;
if (res == 0 && dummy_client)
{

View File

@ -54,7 +54,10 @@ fhandler_pipe::init (HANDLE f, DWORD a, mode_t mode)
a &= ~FILE_CREATE_PIPE_INSTANCE;
fhandler_base::init (f, a, mode);
close_on_exec (mode & O_CLOEXEC);
setup_overlapped (opened_properly);
if (opened_properly)
setup_overlapped ();
else
destroy_overlapped ();
return 1;
}
@ -185,7 +188,7 @@ fhandler_pipe::dup (fhandler_base *child)
ftp->set_popen_pid (0);
int res;
if (get_handle () && fhandler_base::dup (child))
if (get_handle () && fhandler_base_overlapped::dup (child))
res = -1;
else
res = 0;