Allow killsockfilters() to take a 5th optional parameter that when provided
indicates that only one of the two possible sockfilter processes should be killed. Valid values for this parameter are 'main' and 'data'.
This commit is contained in:
41
tests/ftp.pm
41
tests/ftp.pm
@@ -177,36 +177,43 @@ sub killpid {
|
|||||||
# killsockfilters kills sockfilter processes for a given server.
|
# killsockfilters kills sockfilter processes for a given server.
|
||||||
#
|
#
|
||||||
sub killsockfilters {
|
sub killsockfilters {
|
||||||
my ($proto, $ipvnum, $idnum, $verbose) = @_;
|
my ($proto, $ipvnum, $idnum, $verbose, $which) = @_;
|
||||||
my $server;
|
my $server;
|
||||||
my $pidfile;
|
my $pidfile;
|
||||||
my $pid;
|
my $pid;
|
||||||
|
|
||||||
return if($proto !~ /^(ftp|imap|pop3|smtp)$/);
|
return if($proto !~ /^(ftp|imap|pop3|smtp)$/);
|
||||||
|
|
||||||
|
die "unsupported sockfilter: $which"
|
||||||
|
if($which && ($which !~ /^(main|data)$/));
|
||||||
|
|
||||||
$server = servername_id($proto, $ipvnum, $idnum) if($verbose);
|
$server = servername_id($proto, $ipvnum, $idnum) if($verbose);
|
||||||
|
|
||||||
$pidfile = mainsockf_pidfilename($proto, $ipvnum, $idnum);
|
if(!$which || ($which eq 'main')) {
|
||||||
$pid = processexists($pidfile);
|
$pidfile = mainsockf_pidfilename($proto, $ipvnum, $idnum);
|
||||||
if($pid > 0) {
|
$pid = processexists($pidfile);
|
||||||
printf("* kill pid for %s-%s => %d\n", $server,
|
if($pid > 0) {
|
||||||
($proto eq 'ftp')?'ctrl':'filt', $pid) if($verbose);
|
printf("* kill pid for %s-%s => %d\n", $server,
|
||||||
kill("KILL", $pid);
|
($proto eq 'ftp')?'ctrl':'filt', $pid) if($verbose);
|
||||||
waitpid($pid, 0);
|
kill("KILL", $pid);
|
||||||
|
waitpid($pid, 0);
|
||||||
|
}
|
||||||
|
unlink($pidfile) if(-f $pidfile);
|
||||||
}
|
}
|
||||||
unlink($pidfile) if(-f $pidfile);
|
|
||||||
|
|
||||||
return if($proto ne 'ftp');
|
return if($proto ne 'ftp');
|
||||||
|
|
||||||
$pidfile = datasockf_pidfilename($proto, $ipvnum, $idnum);
|
if(!$which || ($which eq 'data')) {
|
||||||
$pid = processexists($pidfile);
|
$pidfile = datasockf_pidfilename($proto, $ipvnum, $idnum);
|
||||||
if($pid > 0) {
|
$pid = processexists($pidfile);
|
||||||
printf("* kill pid for %s-data => %d\n", $server,
|
if($pid > 0) {
|
||||||
$pid) if($verbose);
|
printf("* kill pid for %s-data => %d\n", $server,
|
||||||
kill("KILL", $pid);
|
$pid) if($verbose);
|
||||||
waitpid($pid, 0);
|
kill("KILL", $pid);
|
||||||
|
waitpid($pid, 0);
|
||||||
|
}
|
||||||
|
unlink($pidfile) if(-f $pidfile);
|
||||||
}
|
}
|
||||||
unlink($pidfile) if(-f $pidfile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user