Change 34775 by [EMAIL PROTECTED] on 2008/11/08 05:18:16
Subject: Re: [perl #56644] PerlIO resource leaks on open() and then
:pop in :unix and :stdio
From: "Goro Fuji" <[EMAIL PROTECTED]>
Date: Mon, 7 Jul 2008 08:04:52 +0900
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
... //depot/perl/MANIFEST#1747 edit
... //depot/perl/ext/PerlIO/t/ioleaks.t#1 add
... //depot/perl/perlio.c#394 edit
... //depot/perl/pod/perliol.pod#37 edit
Differences ...
==== //depot/perl/MANIFEST#1747 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST#1746~34773~ 2008-11-07 20:02:03.000000000 -0800
+++ perl/MANIFEST 2008-11-07 21:18:16.000000000 -0800
@@ -969,6 +969,7 @@
ext/PerlIO/t/encoding.t See if PerlIO encoding conversion works
ext/PerlIO/t/fail.t See if bad layers fail
ext/PerlIO/t/fallback.t See if PerlIO fallbacks work
+ext/PerlIO/t/ioleaks.t See if PerlIO layers are leaking
ext/PerlIO/t/open.t See if PerlIO certain special opens work
ext/PerlIO/t/PerlIO.t See if PerlIO works
ext/PerlIO/t/scalar.t See if PerlIO::scalar works
==== //depot/perl/ext/PerlIO/t/ioleaks.t#1 (text) ====
Index: perl/ext/PerlIO/t/ioleaks.t
--- /dev/null 2008-11-04 07:18:13.288883315 -0800
+++ perl/ext/PerlIO/t/ioleaks.t 2008-11-07 21:18:16.000000000 -0800
@@ -0,0 +1,23 @@
+#!perl
+# ioleaks.t
+
+use strict;
+use warnings;
+use Test::More 'no_plan';
+
+# :unix -> not ok
+# :stdio -> not ok
+# :perlio -> ok
+# :crlf -> ok
+
+foreach my $layer(qw(:unix :stdio :perlio :crlf)){
+ my $base_fd = do{ open my $in, '<', $0 or die $!; fileno $in };
+
+ for(1 .. 3){
+ open my $fh, "<$layer", $0 or die $!;
+
+ is fileno($fh), $base_fd, $layer;
+ binmode $fh, ':pop';
+ }
+}
+
==== //depot/perl/perlio.c#394 (text) ====
Index: perl/perlio.c
--- perl/perlio.c#393~34774~ 2008-11-07 20:21:44.000000000 -0800
+++ perl/perlio.c 2008-11-07 21:18:16.000000000 -0800
@@ -2736,10 +2736,15 @@
return PerlLIO_lseek(PerlIOSelf(f, PerlIOUnix)->fd, 0, SEEK_CUR);
}
-
IV
PerlIOUnix_close(pTHX_ PerlIO *f)
{
+ return PerlIOBase_noop_ok(aTHX_ f);
+}
+
+IV
+PerlIOUnix_popped(pTHX_ PerlIO *f)
+{
dVAR;
const int fd = PerlIOSelf(f, PerlIOUnix)->fd;
int code = 0;
@@ -2772,7 +2777,7 @@
sizeof(PerlIOUnix),
PERLIO_K_RAW,
PerlIOUnix_pushed,
- PerlIOBase_popped,
+ PerlIOUnix_popped,
PerlIOUnix_open,
PerlIOBase_binmode, /* binmode */
NULL,
@@ -3122,6 +3127,12 @@
IV
PerlIOStdio_close(pTHX_ PerlIO *f)
{
+ return PerlIOBase_noop_ok(aTHX_ f);
+}
+
+IV
+PerlIOStdio_popped(pTHX_ PerlIO *f)
+{
FILE * const stdio = PerlIOSelf(f, PerlIOStdio)->stdio;
if (!stdio) {
errno = EBADF;
@@ -3558,7 +3569,7 @@
sizeof(PerlIOStdio),
PERLIO_K_BUFFERED|PERLIO_K_RAW,
PerlIOStdio_pushed,
- PerlIOBase_popped,
+ PerlIOStdio_popped,
PerlIOStdio_open,
PerlIOBase_binmode, /* binmode */
NULL,
==== //depot/perl/pod/perliol.pod#37 (text) ====
Index: perl/pod/perliol.pod
--- perl/pod/perliol.pod#36~32026~ 2007-10-04 07:28:34.000000000 -0700
+++ perl/pod/perliol.pod 2008-11-07 21:18:16.000000000 -0800
@@ -145,7 +145,7 @@
IV (*Pushed)(pTHX_ PerlIO *f,const char *mode,SV *arg,
PerlIO_funcs *tab);
IV (*Popped)(pTHX_ PerlIO *f);
PerlIO * (*Open)(pTHX_ PerlIO_funcs *tab,
- AV *layers, IV n,
+ PerlIO_list_t *layers, IV n,
const char *mode,
int fd, int imode, int perm,
PerlIO *old,
@@ -486,7 +486,7 @@
follows:
PerlIO * (*Open)(pTHX_ PerlIO_funcs *tab,
- AV *layers, IV n,
+ PerlIO_list_t *layers, IV n,
const char *mode,
int fd, int imode, int perm,
PerlIO *old,
@@ -494,7 +494,7 @@
Open should (perhaps indirectly) call C<PerlIO_allocate()> to allocate
a slot in the table and associate it with the layers information for
-the opened file, by calling C<PerlIO_push>. The I<layers> AV is an
+the opened file, by calling C<PerlIO_push>. The I<layers> is an
array of all the layers destined for the C<PerlIO *>, and any
arguments passed to them, I<n> is the index into that array of the
layer being called. The macro C<PerlIOArg> will return a (possibly
End of Patch.