Move fork processing code to earlier in file.
This commit is contained in:
parent
26edcca3a3
commit
90466f78e4
1 changed files with 19 additions and 16 deletions
|
@ -137,6 +137,25 @@ while (my $line = <STDIN>) {
|
|||
$WHITELIST_COMMIT_IDS{$line} = $line;
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Set up child processing and signal commits.
|
||||
|
||||
my %childProcesses;
|
||||
my %finishedCommits;
|
||||
|
||||
$SIG{CHLD} = sub {
|
||||
# don't change $! and $? outside handler
|
||||
local ($!, $?);
|
||||
while ( (my $pid = waitpid(-1, WNOHANG)) > 0 ) {
|
||||
my($errCode, $errString) = ($?, $!);
|
||||
my $commitId = $childProcesses{$pid};
|
||||
my $now = strftime("%Y-%m-%d %H:%M:%S", localtime);
|
||||
print STDERR "Finished commit $commitId $childProcesses{$pid} in $pid ($errCode, \"$errString\") at $now\n" if $VERBOSE;
|
||||
$finishedCommits{$commitId} = { pid => $pid, time => $now, errCode => $errCode, errString => $errString };
|
||||
delete $childProcesses{$pid};
|
||||
}
|
||||
};
|
||||
|
||||
##############################################################################
|
||||
# ProcessCommit is the primary function that processes a commit to generate
|
||||
# the blame data. If $fileListRef is defined, it should be a list reference,
|
||||
|
@ -219,22 +238,6 @@ if (defined $CENTRAL_COMMIT) {
|
|||
|
||||
exit 0;
|
||||
|
||||
my %childProcesses;
|
||||
my %finishedCommits;
|
||||
|
||||
$SIG{CHLD} = sub {
|
||||
# don't change $! and $? outside handler
|
||||
local ($!, $?);
|
||||
while ( (my $pid = waitpid(-1, WNOHANG)) > 0 ) {
|
||||
my($errCode, $errString) = ($?, $!);
|
||||
my $commitId = $childProcesses{$pid};
|
||||
my $now = strftime("%Y-%m-%d %H:%M:%S", localtime);
|
||||
print STDERR "Finished commit $commitId $childProcesses{$pid} in $pid ($errCode, \"$errString\") at $now\n" if $VERBOSE;
|
||||
$finishedCommits{$commitId} = { pid => $pid, time => $now, errCode => $errCode, errString => $errString };
|
||||
delete $childProcesses{$pid};
|
||||
}
|
||||
};
|
||||
|
||||
foreach my $commitId (keys %WHITELIST_COMMIT_IDS) {
|
||||
my $remainingCount = scalar(keys %childProcesses);
|
||||
while ($remainingCount >= $FORK_LIMIT) {
|
||||
|
|
Loading…
Reference in a new issue