From 76e6a376c129e1df71d7eab7827b3e933dfec127 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Sat, 7 Mar 2009 17:04:11 -0800 Subject: Fix problems caused by GetOptions() change. When using closure form of GetOptions, any call to exit only causes GetOptions error rather than exit of program. Since QoS uses die to indicate transaction error, this doesn't work well! --- scripts/vyatta-qos.pl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/vyatta-qos.pl b/scripts/vyatta-qos.pl index 704b219..1182089 100755 --- a/scripts/vyatta-qos.pl +++ b/scripts/vyatta-qos.pl @@ -82,6 +82,7 @@ sub list_policy { } print join( ' ', @nodes ), "\n"; + exit 0; } ## delete_interface('eth0', 'out') @@ -292,6 +293,7 @@ sub delete_policy { # can't delete active policy die "Must delete QoS policy from interfaces before deleting rules\n"; } + exit 0; } sub check_conflict { @@ -360,10 +362,12 @@ my @updateInterface = (); my @deleteInterface = (); my @createPolicy = (); +my ($check, $apply, $start); + GetOptions( - "check" => sub { check_conflict(); }, - "apply" => sub { apply_changes(); }, - "start-interface=s" => sub { start_interface( $_[1] ); }, + "check" => \$check, + "apply" => \$apply, + "start-interface=s" => \$start, "update-interface=s{3}" => \@updateInterface, "delete-interface=s{2}" => \@deleteInterface, @@ -372,6 +376,10 @@ GetOptions( "create-policy=s{2}" => \@createPolicy, ) or usage(); +apply_changes() if $apply; +check_conflict() if $check; + delete_interface(@deleteInterface) if ( $#deleteInterface == 1 ); update_interface(@updateInterface) if ( $#updateInterface == 2 ); +start_interface( $start ) if $start; create_policy(@createPolicy) if ( $#createPolicy == 1); -- cgit v1.2.3