Fixed zombie processes are created when xml transfer is timed out.
(cherry picked from commit 41e6d71159
)
This commit is contained in:
parent
27624a4d70
commit
861a749654
|
@ -824,40 +824,52 @@ sub send_file {
|
|||
my ($file, $secondary) = @_;
|
||||
my $output;
|
||||
|
||||
eval {
|
||||
local $SIG{'ALRM'} = sub {die};
|
||||
alarm ($Conf{'transfer_timeout'});
|
||||
if ($Conf{'transfer_mode'} eq 'tentacle') {
|
||||
$output = `tentacle_client -v -a $Conf{'server_ip'} -p $Conf{'server_port'} $Conf{'server_opts'} "$file" 2>&1 >$DevNull`;
|
||||
} elsif ($Conf{'transfer_mode'} eq 'ssh') {
|
||||
$output = `scp -P $Conf{'server_port'} "$file" pandora@"$Conf{'server_ip'}:$Conf{'server_path'}" 2>&1 >$DevNull`;
|
||||
} elsif ($Conf{'transfer_mode'} eq 'ftp') {
|
||||
my $base = basename ($file);
|
||||
my $dir = dirname ($file);
|
||||
my $pid = fork();
|
||||
return 1 unless defined $pid;
|
||||
|
||||
if ($pid == 0) {
|
||||
# execute the transfer program by child process.
|
||||
eval {
|
||||
local $SIG{'ALRM'} = sub {die};
|
||||
alarm ($Conf{'transfer_timeout'});
|
||||
if ($Conf{'transfer_mode'} eq 'tentacle') {
|
||||
$output = `tentacle_client -v -a $Conf{'server_ip'} -p $Conf{'server_port'} $Conf{'server_opts'} "$file" 2>&1 >$DevNull`;
|
||||
} elsif ($Conf{'transfer_mode'} eq 'ssh') {
|
||||
$output = `scp -P $Conf{'server_port'} "$file" pandora@"$Conf{'server_ip'}:$Conf{'server_path'}" 2>&1 >$DevNull`;
|
||||
} elsif ($Conf{'transfer_mode'} eq 'ftp') {
|
||||
my $base = basename ($file);
|
||||
my $dir = dirname ($file);
|
||||
|
||||
$output = `ftp -n $Conf{'server_opts'} $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >$DevNull <<FEOF1
|
||||
quote USER $Conf{'server_user'}
|
||||
quote PASS $Conf{'server_pwd'}
|
||||
lcd "$dir"
|
||||
cd "$Conf{'server_path'}"
|
||||
put "$base"
|
||||
quit
|
||||
FEOF1`
|
||||
} elsif ($Conf{'transfer_mode'} eq 'local') {
|
||||
$output = `cp "$file" "$Conf{'server_path'}/" 2>&1 >$DevNull`;
|
||||
}
|
||||
alarm (0);
|
||||
};
|
||||
$output = `ftp -n $Conf{'server_opts'} $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >$DevNull <<FEOF1
|
||||
quote USER $Conf{'server_user'}
|
||||
quote PASS $Conf{'server_pwd'}
|
||||
lcd "$dir"
|
||||
cd "$Conf{'server_path'}"
|
||||
put "$base"
|
||||
quit
|
||||
FEOF1`
|
||||
} elsif ($Conf{'transfer_mode'} eq 'local') {
|
||||
$output = `cp "$file" "$Conf{'server_path'}/" 2>&1 >$DevNull`;
|
||||
}
|
||||
alarm (0);
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
$output = "File transfer command is not responding.";
|
||||
if ($@) {
|
||||
log_message ('error', "Error sending file '$file': File transfer command is not responding.");
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Get the errorlevel
|
||||
my $rc = $? >> 8;
|
||||
if ($rc != 0) {
|
||||
log_message ('error', "Error sending file '$file': $output");
|
||||
}
|
||||
exit $rc;
|
||||
}
|
||||
|
||||
# Get the errorlevel
|
||||
# Wait the child process termination and get the errorlevel
|
||||
waitpid ($pid, 0);
|
||||
my $rc = $? >> 8;
|
||||
if ($rc != 0 || $@) {
|
||||
log_message ('error', "Error sending file '$file': $output");
|
||||
}
|
||||
|
||||
return $rc unless (defined ($secondary));
|
||||
|
||||
|
@ -916,40 +928,52 @@ sub recv_file ($) {
|
|||
my $file = shift;
|
||||
my $output;
|
||||
|
||||
eval {
|
||||
local $SIG{'ALRM'} = sub {die};
|
||||
alarm ($Conf{'transfer_timeout'});
|
||||
if ($Conf{'transfer_mode'} eq 'tentacle') {
|
||||
$output = `cd "$Conf{'temporal'}"$CmdSep tentacle_client -v -g -a $Conf{'server_ip'} -p $Conf{'server_port'} $Conf{'server_opts'} $file 2>&1 >$DevNull`
|
||||
} elsif ($Conf{'transfer_mode'} eq 'ssh') {
|
||||
$output = `scp -P $Conf{'server_port'} pandora@"$Conf{'server_ip'}:$Conf{'server_path'}/$file" $Conf{'temporal'} 2>&1 >$DevNull`;
|
||||
} elsif ($Conf{'transfer_mode'} eq 'ftp') {
|
||||
my $base = basename ($file);
|
||||
my $dir = dirname ($file);
|
||||
my $pid = fork();
|
||||
return 1 unless defined $pid;
|
||||
|
||||
$output = `ftp -n $Conf{'server_opts'} $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >$DevNull <<FEOF1
|
||||
quote USER $Conf{'server_user'}
|
||||
quote PASS $Conf{'server_pwd'}
|
||||
lcd "$Conf{'temporal'}"
|
||||
cd "$Conf{'server_path'}"
|
||||
get "$file"
|
||||
quit
|
||||
FEOF1`
|
||||
} elsif ($Conf{'transfer_mode'} eq 'local') {
|
||||
$output = `cp $Conf{'server_path'}/$file $Conf{'temporal'} 2>&1 >$DevNull`;
|
||||
if ($pid == 0) {
|
||||
# execute the transfer program by child process.
|
||||
eval {
|
||||
local $SIG{'ALRM'} = sub {die};
|
||||
alarm ($Conf{'transfer_timeout'});
|
||||
if ($Conf{'transfer_mode'} eq 'tentacle') {
|
||||
$output = `cd "$Conf{'temporal'}"$CmdSep tentacle_client -v -g -a $Conf{'server_ip'} -p $Conf{'server_port'} $Conf{'server_opts'} $file 2>&1 >$DevNull`
|
||||
} elsif ($Conf{'transfer_mode'} eq 'ssh') {
|
||||
$output = `scp -P $Conf{'server_port'} pandora@"$Conf{'server_ip'}:$Conf{'server_path'}/$file" $Conf{'temporal'} 2>&1 >$DevNull`;
|
||||
} elsif ($Conf{'transfer_mode'} eq 'ftp') {
|
||||
my $base = basename ($file);
|
||||
my $dir = dirname ($file);
|
||||
|
||||
$output = `ftp -n $Conf{'server_opts'} $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >$DevNull <<FEOF1
|
||||
quote USER $Conf{'server_user'}
|
||||
quote PASS $Conf{'server_pwd'}
|
||||
lcd "$Conf{'temporal'}"
|
||||
cd "$Conf{'server_path'}"
|
||||
get "$file"
|
||||
quit
|
||||
FEOF1`
|
||||
} elsif ($Conf{'transfer_mode'} eq 'local') {
|
||||
$output = `cp $Conf{'server_path'}/$file $Conf{'temporal'} 2>&1 >$DevNull`;
|
||||
}
|
||||
alarm (0);
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
log_message ('error', "Error retrieving file: File transfer command is not responding.");
|
||||
exit 1;
|
||||
}
|
||||
alarm (0);
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
$output = "File transfer command is not responding.";
|
||||
# Get the errorlevel
|
||||
my $rc = $? >> 8;
|
||||
if ($rc != 0) {
|
||||
log_message ('error', "Error retrieving file: $output");
|
||||
}
|
||||
exit $rc;
|
||||
}
|
||||
|
||||
# Get the errorlevel
|
||||
# Wait the child process termination and get the errorlevel
|
||||
waitpid ($pid, 0);
|
||||
my $rc = $? >> 8;
|
||||
if ($rc != 0 || $@) {
|
||||
log_message ('error', "Error retrieving file: $output");
|
||||
}
|
||||
|
||||
return $rc;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue