* dtable.cc (build_fh_dev): Take additional bool parameter indicating

whether set_name should be called or not.
	(dtable::dup_worker): Call build_fh_pc with new second parameter set
	to false.  Explain why.  If fhandler's dup failed, delete rather than
	cfree newfh and set newfh to NULL to indicate failure correctly.
	* dtable.h (build_fh_pc): Change declaration according to above change.
	Default set_name parameter to true.
	* mmap.cc (mmap_record::free_fh): Delete rather than cfree fh.
This commit is contained in:
Corinna Vinschen 2009-08-20 08:34:21 +00:00
parent 5546e07b4f
commit 1c1b04b84c
4 changed files with 23 additions and 8 deletions

View File

@ -1,3 +1,14 @@
2009-08-20 Corinna Vinschen <corinna@vinschen.de>
* dtable.cc (build_fh_dev): Take additional bool parameter indicating
whether set_name should be called or not.
(dtable::dup_worker): Call build_fh_pc with new second parameter set
to false. Explain why. If fhandler's dup failed, delete rather than
cfree newfh and set newfh to NULL to indicate failure correctly.
* dtable.h (build_fh_pc): Change declaration according to above change.
Default set_name parameter to true.
* mmap.cc (mmap_record::free_fh): Delete rather than cfree fh.
2009-08-18 Christopher Faylor <me+cygwin@cgf.cx>
* dtable.cc (dtable::fixup_after_exec): Close any popen'ed file handles here.

View File

@ -444,7 +444,7 @@ build_fh_dev (const device& dev, const char *unix_name)
#define fh_unset ((fhandler_base *) 1)
fhandler_base *
build_fh_pc (path_conv& pc)
build_fh_pc (path_conv& pc, bool set_name)
{
fhandler_base *fh = fh_unset;
@ -564,10 +564,10 @@ build_fh_pc (path_conv& pc)
if (fh == fh_unset)
fh = cnew (fhandler_nodevice) ();
if (fh)
fh->set_name (pc);
else
if (!fh)
set_errno (EMFILE);
else if (set_name)
fh->set_name (pc);
debug_printf ("fh %p", fh);
return fh;
@ -576,7 +576,10 @@ build_fh_pc (path_conv& pc)
fhandler_base *
dtable::dup_worker (fhandler_base *oldfh)
{
fhandler_base *newfh = build_fh_pc (oldfh->pc);
/* Don't call set_name in build_fh_pc. It will be called in
fhandler_base::operator= below. Calling it twice will result
in double allocation. */
fhandler_base *newfh = build_fh_pc (oldfh->pc, false);
if (!newfh)
debug_printf ("build_fh_pc failed");
else
@ -585,7 +588,8 @@ dtable::dup_worker (fhandler_base *oldfh)
newfh->set_io_handle (NULL);
if (oldfh->dup (newfh))
{
cfree (newfh);
delete newfh;
newfh = NULL;
debug_printf ("oldfh->dup failed");
}
else

View File

@ -83,7 +83,7 @@ public:
fhandler_base *build_fh_dev (const device&, const char * = NULL);
fhandler_base *build_fh_name (const char *, HANDLE = NULL, unsigned = 0, suffix_info * = NULL);
fhandler_base *build_fh_name (const UNICODE_STRING *, HANDLE = NULL, unsigned = 0, suffix_info * = NULL);
fhandler_base *build_fh_pc (path_conv& pc);
fhandler_base *build_fh_pc (path_conv& pc, bool set_name = true);
void dtable_init ();
void stdio_init ();

View File

@ -536,7 +536,7 @@ void
mmap_record::free_fh (fhandler_base *fh)
{
if (!anonymous ())
cfree (fh);
delete fh;
}
mmap_record *