# New Ticket Created by Jeff Horwitz
# Please include the string: [perl #45787]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=45787 >
make -j N has failed for some time. the attached patch fixes the problem
by synchronizing the execution of c2str.pl, which needs exclusive access
to its output file.
-jeff
Index: tools/build/c2str.pl
===================================================================
--- tools/build/c2str.pl (revision 21458)
+++ tools/build/c2str.pl (working copy)
@@ -19,7 +19,22 @@
my $outfile = 'all_cstring.str';
my $string_private_h = 'src/string_private_cstring.h';
+my $lockfile = "$outfile.lck";
+my $max_lock_wait = 120;
+my $start_time = time;
+while ( -e $lockfile ) {
+ sleep 1;
+ if ( time - $start_time > $max_lock_wait ) {
+ die "Lock still held after $max_lock_wait seconds -- something is
wrong!";
+ }
+}
+open my $lock, '>', $lockfile or die "Can't write '$lockfile': $!";
+print $lock "$$\n";
+close $lock;
+
+$SIG{'__DIE__'} = sub { unlink $lockfile };
+
my ( $result, $do_all, $do_init, $file );
$result = GetOptions(
"all" => \$do_all,
@@ -29,10 +44,12 @@
$do_all and do {
&read_all;
&create_c_include;
+ unlink $lockfile;
exit;
};
$do_init and do {
unlink $outfile;
+ unlink $lockfile;
exit;
};
@@ -49,6 +66,8 @@
process_cfile();
close $ALL;
+unlink $lockfile;
+
sub hash_val {
my $h = Math::BigInt->new('+0');
my $s = shift;