diff options
author | Yang Tse <yangsita@gmail.com> | 2010-01-20 20:39:56 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2010-01-20 20:39:56 +0000 |
commit | 422a7869be706eac6fa19c0fbbcfcaa348ffb2e4 (patch) | |
tree | 9ea9de9915c7a54ff64047210d62295e1bc793ed | |
parent | 471e8eefb66f6de9a70ddb9dc79bd894374043ec (diff) |
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'.
-rw-r--r-- | tests/ftp.pm | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/tests/ftp.pm b/tests/ftp.pm index 0f4976c7c..2be547fc7 100644 --- a/tests/ftp.pm +++ b/tests/ftp.pm @@ -177,36 +177,43 @@ sub killpid { # killsockfilters kills sockfilter processes for a given server. # sub killsockfilters { - my ($proto, $ipvnum, $idnum, $verbose) = @_; + my ($proto, $ipvnum, $idnum, $verbose, $which) = @_; my $server; my $pidfile; my $pid; return if($proto !~ /^(ftp|imap|pop3|smtp)$/); + die "unsupported sockfilter: $which" + if($which && ($which !~ /^(main|data)$/)); + $server = servername_id($proto, $ipvnum, $idnum) if($verbose); - $pidfile = mainsockf_pidfilename($proto, $ipvnum, $idnum); - $pid = processexists($pidfile); - if($pid > 0) { - printf("* kill pid for %s-%s => %d\n", $server, - ($proto eq 'ftp')?'ctrl':'filt', $pid) if($verbose); - kill("KILL", $pid); - waitpid($pid, 0); + if(!$which || ($which eq 'main')) { + $pidfile = mainsockf_pidfilename($proto, $ipvnum, $idnum); + $pid = processexists($pidfile); + if($pid > 0) { + printf("* kill pid for %s-%s => %d\n", $server, + ($proto eq 'ftp')?'ctrl':'filt', $pid) if($verbose); + kill("KILL", $pid); + waitpid($pid, 0); + } + unlink($pidfile) if(-f $pidfile); } - unlink($pidfile) if(-f $pidfile); return if($proto ne 'ftp'); - $pidfile = datasockf_pidfilename($proto, $ipvnum, $idnum); - $pid = processexists($pidfile); - if($pid > 0) { - printf("* kill pid for %s-data => %d\n", $server, - $pid) if($verbose); - kill("KILL", $pid); - waitpid($pid, 0); + if(!$which || ($which eq 'data')) { + $pidfile = datasockf_pidfilename($proto, $ipvnum, $idnum); + $pid = processexists($pidfile); + if($pid > 0) { + printf("* kill pid for %s-data => %d\n", $server, + $pid) if($verbose); + kill("KILL", $pid); + waitpid($pid, 0); + } + unlink($pidfile) if(-f $pidfile); } - unlink($pidfile) if(-f $pidfile); } ####################################################################### |