summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2013-07-03 20:26:44 +0000
committerChristopher Faylor <me@cgf.cx>2013-07-03 20:26:44 +0000
commit470b8544e8d48d05b9210a7de38fe76b65e29658 (patch)
tree28c40818f8e849d79e3be16de267e369fd7dca48 /winsup/cygwin/fhandler.cc
parent2404223df651ceef42c6e2f2c9fa42fb7963db10 (diff)
downloadcygnal-470b8544e8d48d05b9210a7de38fe76b65e29658.tar.gz
cygnal-470b8544e8d48d05b9210a7de38fe76b65e29658.tar.bz2
cygnal-470b8544e8d48d05b9210a7de38fe76b65e29658.zip
* fhandler.cc (fhandler_base::close_with_arch): Make sure that the archetype is
deleted when close_with_arch is referenced *via* the archetype.
Diffstat (limited to 'winsup/cygwin/fhandler.cc')
-rw-r--r--winsup/cygwin/fhandler.cc30
1 files changed, 14 insertions, 16 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 6c284a596..920ab7f49 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -1076,32 +1076,30 @@ fhandler_base::close_with_arch ()
fhandler_base *fh;
if (usecount)
{
- if (!--usecount)
- debug_printf ("closing passed in archetype, usecount %d", usecount);
- else
+ /* This was the archetype itself. */
+ if (--usecount)
{
- debug_printf ("not closing passed in archetype, usecount %d", usecount);
+ debug_printf ("not closing passed in archetype %p, usecount %d", archetype, usecount);
return 0;
}
- fh = this;
+ debug_printf ("closing passed in archetype %p, usecount %d", archetype, usecount);
+ /* Set archetype temporarily so that it will eventually be deleted. */
+ archetype = fh = this;
}
else if (!archetype)
fh = this;
+ else if (archetype_usecount (-1) == 0)
+ {
+ debug_printf ("closing archetype");
+ fh = archetype;
+ }
else
{
- cleanup ();
- if (archetype_usecount (-1) == 0)
- {
- debug_printf ("closing archetype");
- fh = archetype;
- }
- else
- {
- debug_printf ("not closing archetype");
- return 0;
- }
+ debug_printf ("not closing archetype");
+ return 0;
}
+ cleanup ();
res = fh->close ();
if (archetype)
{