summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2006-10-18 16:07:54 -0400
committerSteve Peters <steve@fisharerojo.org>2006-10-19 01:18:50 +0000
commite47547a83f24974bde05453531e68d7dd8c5ec87 (patch)
treee832433e3323ea77e78b105d33f5cabf916b4f5e /perlio.c
parent59b085e1644b14873900cf449944e1ed94f075d3 (diff)
downloadperl-e47547a83f24974bde05453531e68d7dd8c5ec87.tar.gz
blead valgrind finding
Message-ID: <4536C1DA.4060600@iki.fi> p4raw-id: //depot/perl@29045
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/perlio.c b/perlio.c
index ddc0ad8309..63164c4aa7 100644
--- a/perlio.c
+++ b/perlio.c
@@ -2367,6 +2367,20 @@ PerlIO_cleanup(pTHX)
#else
PerlIO_debug("Cleanup layers\n");
#endif
+
+#ifdef DEBUGGING
+ {
+ /* By now all filehandles should have been closed, so any
+ * stray (non-STD-)filehandles indicate *possible* (PerlIO)
+ * errors. */
+ for (i = 3; i < PL_perlio_fd_refcnt_size; i++) {
+ if (PL_perlio_fd_refcnt[i])
+ PerlIO_debug("PerlIO_cleanup: fd %d refcnt=%d\n",
+ i, PL_perlio_fd_refcnt[i]);
+ }
+ }
+#endif
+
/* Raise STDIN..STDERR refcount so we don't close them */
for (i=0; i < 3; i++)
PerlIOUnix_refcnt_inc(i);
@@ -2383,6 +2397,15 @@ PerlIO_cleanup(pTHX)
PerlIO_list_free(aTHX_ PL_def_layerlist);
PL_def_layerlist = NULL;
}
+
+#ifdef USE_ITHREADS
+ /* only main thread can free refcnt table */
+ if (PL_curinterp == aTHX)
+#endif
+ {
+ Safefree(PL_perlio_fd_refcnt);
+ PL_perlio_fd_refcnt = NULL;
+ }
}