mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
Fixed zombie processes are created when xml transfer is timed out.
This commit is contained in:
parent
9697c1fcf0
commit
41e6d71159
@ -824,40 +824,52 @@ sub send_file {
|
|||||||
my ($file, $secondary) = @_;
|
my ($file, $secondary) = @_;
|
||||||
my $output;
|
my $output;
|
||||||
|
|
||||||
eval {
|
my $pid = fork();
|
||||||
local $SIG{'ALRM'} = sub {die};
|
return 1 unless defined $pid;
|
||||||
alarm ($Conf{'transfer_timeout'});
|
|
||||||
if ($Conf{'transfer_mode'} eq 'tentacle') {
|
if ($pid == 0) {
|
||||||
$output = `tentacle_client -v -a $Conf{'server_ip'} -p $Conf{'server_port'} $Conf{'server_opts'} "$file" 2>&1 >$DevNull`;
|
# execute the transfer program by child process.
|
||||||
} elsif ($Conf{'transfer_mode'} eq 'ssh') {
|
eval {
|
||||||
$output = `scp -P $Conf{'server_port'} "$file" pandora@"$Conf{'server_ip'}:$Conf{'server_path'}" 2>&1 >$DevNull`;
|
local $SIG{'ALRM'} = sub {die};
|
||||||
} elsif ($Conf{'transfer_mode'} eq 'ftp') {
|
alarm ($Conf{'transfer_timeout'});
|
||||||
my $base = basename ($file);
|
if ($Conf{'transfer_mode'} eq 'tentacle') {
|
||||||
my $dir = dirname ($file);
|
$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
|
$output = `ftp -n $Conf{'server_opts'} $Conf{'server_ip'} $Conf{'server_port'} 2>&1 >$DevNull <<FEOF1
|
||||||
quote USER $Conf{'server_user'}
|
quote USER $Conf{'server_user'}
|
||||||
quote PASS $Conf{'server_pwd'}
|
quote PASS $Conf{'server_pwd'}
|
||||||
lcd "$dir"
|
lcd "$dir"
|
||||||
cd "$Conf{'server_path'}"
|
cd "$Conf{'server_path'}"
|
||||||
put "$base"
|
put "$base"
|
||||||
quit
|
quit
|
||||||
FEOF1`
|
FEOF1`
|
||||||
} elsif ($Conf{'transfer_mode'} eq 'local') {
|
} elsif ($Conf{'transfer_mode'} eq 'local') {
|
||||||
$output = `cp "$file" "$Conf{'server_path'}/" 2>&1 >$DevNull`;
|
$output = `cp "$file" "$Conf{'server_path'}/" 2>&1 >$DevNull`;
|
||||||
}
|
}
|
||||||
alarm (0);
|
alarm (0);
|
||||||
};
|
};
|
||||||
|
|
||||||
if ($@) {
|
if ($@) {
|
||||||
$output = "File transfer command is not responding.";
|
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;
|
my $rc = $? >> 8;
|
||||||
if ($rc != 0 || $@) {
|
|
||||||
log_message ('error', "Error sending file '$file': $output");
|
|
||||||
}
|
|
||||||
|
|
||||||
return $rc unless (defined ($secondary));
|
return $rc unless (defined ($secondary));
|
||||||
|
|
||||||
@ -916,40 +928,52 @@ sub recv_file ($) {
|
|||||||
my $file = shift;
|
my $file = shift;
|
||||||
my $output;
|
my $output;
|
||||||
|
|
||||||
eval {
|
my $pid = fork();
|
||||||
local $SIG{'ALRM'} = sub {die};
|
return 1 unless defined $pid;
|
||||||
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
|
if ($pid == 0) {
|
||||||
quote USER $Conf{'server_user'}
|
# execute the transfer program by child process.
|
||||||
quote PASS $Conf{'server_pwd'}
|
eval {
|
||||||
lcd "$Conf{'temporal'}"
|
local $SIG{'ALRM'} = sub {die};
|
||||||
cd "$Conf{'server_path'}"
|
alarm ($Conf{'transfer_timeout'});
|
||||||
get "$file"
|
if ($Conf{'transfer_mode'} eq 'tentacle') {
|
||||||
quit
|
$output = `cd "$Conf{'temporal'}"$CmdSep tentacle_client -v -g -a $Conf{'server_ip'} -p $Conf{'server_port'} $Conf{'server_opts'} $file 2>&1 >$DevNull`
|
||||||
FEOF1`
|
} elsif ($Conf{'transfer_mode'} eq 'ssh') {
|
||||||
} elsif ($Conf{'transfer_mode'} eq 'local') {
|
$output = `scp -P $Conf{'server_port'} pandora@"$Conf{'server_ip'}:$Conf{'server_path'}/$file" $Conf{'temporal'} 2>&1 >$DevNull`;
|
||||||
$output = `cp $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 ($@) {
|
# Get the errorlevel
|
||||||
$output = "File transfer command is not responding.";
|
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;
|
my $rc = $? >> 8;
|
||||||
if ($rc != 0 || $@) {
|
|
||||||
log_message ('error', "Error retrieving file: $output");
|
|
||||||
}
|
|
||||||
|
|
||||||
return $rc;
|
return $rc;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user