[Bps-public-commit] r16253 - in Pushmi/trunk: Pushmi-Admin/lib/Pushmi/Admin/Model lib/Pushmi
alexmv at bestpractical.com
alexmv at bestpractical.com
Wed Oct 8 22:32:58 EDT 2008
Author: alexmv
Date: Wed Oct 8 22:32:58 2008
New Revision: 16253
Modified:
Pushmi/trunk/ (props changed)
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm
Pushmi/trunk/lib/Pushmi/Mirror.pm
Log:
r38046 at kohr-ah: chmrr | 2008-10-08 22:32:45 -0400
* SIG{CHLD} = 'IGNORE' causes svk's subprocesses to break (!?)
* Double-fork and waitpid instead, to eliminate zombies
* Make sure PUSHMI_CONFIG and JIFTY_APP_ROOT are set when creating
mirrors, so they are put into hook scripts
* Reduce code duplication when writing hook scripts
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm Wed Oct 8 22:32:58 2008
@@ -57,9 +57,6 @@
since '0.0.3';
};
-# Ignore all children when they die
-$SIG{CHLD} = 'IGNORE';
-
sub validate_name {
my $self = shift;
my $name = shift;
@@ -105,6 +102,8 @@
mkpath( $self->file_root );
eval {
+ local $ENV{PUSHMI_CONFIG} = $self->config_file;
+ local $ENV{JIFTY_APP_ROOT} = Jifty::Util->app_root;
Pushmi::Command::Mirror->new->run( $self->svn_root, $self->url );
};
my $err = $@;
@@ -161,12 +160,15 @@
sub exec_pushmi {
my $self = shift;
my @args = @_;
- unless (fork) {
+ my $child;
+ unless ($child = fork) {
+ exit if fork; # Double-fork to not cause zombies
$ENV{PUSHMI_CONFIG} = $self->config_file;
$ENV{JIFTY_APP_ROOT} = Jifty::Util->app_root;
exec($^X, "-I".(Jifty::Util->app_root)."/lib", Jifty->config->app("pushmi_bin"), @args, "--silent");
}
$self->clear_cache;
+ waitpid($child, 0); # Reap the child
}
sub sync {
@@ -345,7 +347,6 @@
sub start_watcher {
my $self = shift;
- $SIG{CHLD} = sub { print STDERR "sigchld: $!" while wait > 0; };
Jifty->bus->modify(
watchers => sub {
return
Modified: Pushmi/trunk/lib/Pushmi/Mirror.pm
==============================================================================
--- Pushmi/trunk/lib/Pushmi/Mirror.pm (original)
+++ Pushmi/trunk/lib/Pushmi/Mirror.pm Wed Oct 8 22:32:58 2008
@@ -94,49 +94,23 @@
my $perl = join( ' ', $^X, map {"'-I$_'"} grep {not ref $_} @INC );
my $pushmi = can_run('pushmi') or die "can't find pushmi";
- no warnings 'uninitialized';
-
_install_hook( $self->path, 'pre-commit', << "END");
-#!/bin/sh
-export SVKNOSVNCONFIG=1
-export PUSHMI_CONFIG=$ENV{PUSHMI_CONFIG}
-export LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}
-export DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}
-export PATH=$ENV{PATH}
$perl $pushmi runhook \$1 --txnname \$2
END
_install_hook( $self->path, 'post-commit', << "END");
-#!/bin/sh
-export SVKNOSVNCONFIG=1
-export PUSHMI_CONFIG=$ENV{PUSHMI_CONFIG}
-export LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}
-export DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}
-export PATH=$ENV{PATH}
$perl $pushmi unlock \$1 --revision \$2
$perl $pushmi verify \$1 --revision \$2 &
END
_install_hook( $self->path, 'pre-lock', << "END");
-#!/bin/sh
-export SVKNOSVNCONFIG=1
-export PUSHMI_CONFIG=$ENV{PUSHMI_CONFIG}
-export LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}
-export DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}
-export PATH=$ENV{PATH}
$perl $pushmi runlock "\$1" --path "\$2" --user "\$3" --comment "\$4" --steal "\$5"
END
_install_hook( $self->path, 'pre-unlock', << "END");
-#!/bin/sh
-export SVKNOSVNCONFIG=1
-export PUSHMI_CONFIG=$ENV{PUSHMI_CONFIG}
-export LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}
-export DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}
-export PATH=$ENV{PATH}
$perl $pushmi rununlock "\$1" --path "\$2" --user "\$3" --token "\$4" --break "\$5"
END
@@ -149,6 +123,11 @@
my $hpath = "$repospath/hooks/$hook";
open my $fh, '>', $hpath or die $!;
+ print $fh "#!/bin/sh\n";
+ print $fh "export SVKNOSVNCONFIG=1\n";
+ print $fh "export $_=$ENV{$_}\n"
+ for grep { $ENV{$_} }
+ qw/PUSHMI_CONFIG JIFTY_APP_ROOT LD_LIBRARY_PATH DYLD_LIBRARY_PATH PATH/;
print $fh $content;
close $fh;
More information about the Bps-public-commit
mailing list