summaryrefslogtreecommitdiff
path: root/scripts/vyatta-qos.pl
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-03-17 10:38:08 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-03-17 10:38:08 -0700
commitc667c9b128af7a9d8344459c8c65ee9ee8703f02 (patch)
tree7d81e69553460d081b899016bcc6b0c9e395baa5 /scripts/vyatta-qos.pl
parent426d6086ebecea13fe29721130f071284ebca899 (diff)
downloadvyatta-cfg-qos-c667c9b128af7a9d8344459c8c65ee9ee8703f02.tar.gz
vyatta-cfg-qos-c667c9b128af7a9d8344459c8c65ee9ee8703f02.zip
Use select to avoid passing output path around
Easier to just use 'select' in perl to avoid passing file descriptor everywhere.
Diffstat (limited to 'scripts/vyatta-qos.pl')
-rwxr-xr-xscripts/vyatta-qos.pl18
1 files changed, 8 insertions, 10 deletions
diff --git a/scripts/vyatta-qos.pl b/scripts/vyatta-qos.pl
index 8b8b978..328e8d7 100755
--- a/scripts/vyatta-qos.pl
+++ b/scripts/vyatta-qos.pl
@@ -157,26 +157,24 @@ sub update_interface {
# When doing debugging just echo the commands
my $out;
- if ( defined $debug ) {
- open $out, '>-'
- or die "can't open stdout: $!";
- }
- else {
+ unless ($debug) {
open $out, "|-"
or exec qw:sudo /sbin/tc -batch -:
or die "Tc setup failed: $!\n";
+
+ select $out;
}
- $shaper->commands( $out, $device, $direction );
- if ( !close $out && !defined $debug ) {
+ $shaper->commands( $device, $direction );
+ return if ($debug);
+ select STDOUT;
+ unless (close $out) {
# cleanup any partial commands
delete_interface( $device, $direction );
# replay commands to stdout
- open $out, '>-';
- $shaper->commands( $out, $device, $direction );
- close $out;
+ $shaper->commands($device, $direction );
die "TC command failed.";
}
}