develooper Front page | perl.perl5.porters | Postings from December 2018

Bug #133314 for perl5: in-place editing in 5.28 quickly exhaustsopen file descriptor limit

Thread Next
From:
Joe Smith
Date:
December 2, 2018 06:19
Subject:
Bug #133314 for perl5: in-place editing in 5.28 quickly exhaustsopen file descriptor limit
Message ID:
CA+PLHcHeCE2omo2MFTPGB9XYXQ0oL0yEh3qvsraAE=ib2ccCUw@mail.gmail.com
The test for this bug did not make it to the 5.28.1
distribution, and it tested a single file, not 1020 files.

From: James E Keenan <jkeenan@cpan.org> Date: Sun, 1 Jul 2018 22:25:59
-0400 Subject: [PATCH] Test correction to safe in-place editing. For: RT
133314 --- t/run/switches.t | 22 +++++++++++++++++++++- 1 file changed, 21
insertions(+), 1 deletion(-) diff --git a/t/run/switches.t
b/t/run/switches.t index 7ccef1e..c87d016 100644 --- a/t/run/switches.t +++
b/t/run/switches.t @@ -12,7 +12,7 @@ BEGIN { BEGIN { require "./test.pl";
require "./loc_tools.pl"; } -plan(tests => 137); +plan(tests => 138); use
Config; @@ -699,3 +699,23 @@ SWTEST ); like( $r, qr/ok/, 'Spaces on the #!
line (#30660)' ); } + +# RT #133314 + +{ + my $count = 1020; + my $fcount =
sprintf("%04d" => $count); + print STDOUT "XXX: ", (join '|' => $count,
$fcount), "\n"; + for (my $i=1; $i<=$count; $i++) { + my $tfile = (-d "t" ?
"t/" : ""). "switches.133314.$$.$fcount.tmp"; + open my $f, ">$tfile" or
skip("Can't write temp file $tfile: $!"); + close $f; + push @tmpfiles,
$tfile; + } + $r = runperl( + switches => [ '-pi' ], + prog => 's/a/b/', +
args => [ "*switches.133314.*" ], + ), + is( $r, '', "RT \#133314: Safe
in-place editing can handle at least $count files"); +} -- 2.7.4

The definition of $tfile does not include $i, therefore it does
not change in the loop.  Changing $i to a string increment means it can be
used instead of $fcount.

 for (my $i='0001'; $i le $fcount; $i++)
    my $tfile = (-d 't' ? 't/' : '')."switches.133314.$$.$i.tmp"

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About