diff --git a/src/etc/inc/shaper.inc b/src/etc/inc/shaper.inc index cc4005f608..f9388349d1 100644 --- a/src/etc/inc/shaper.inc +++ b/src/etc/inc/shaper.inc @@ -998,15 +998,28 @@ class priq_queue { } function CheckBandwidth($bw, $bwtype) { $parent = $this->GetParent(); - $sum = $parent->GetTotalBw(($bw > 0) ? $this : NULL); - if ($bw > 0) - $sum += get_bandwidth($bw, $bwtype, $parent); - if ($sum > get_queue_bandwidth($parent)) - return 1; + + // If the child queues have bandwidth specified in %, there is no point trying + // to compare the total to the parent's bandwidth, which is defined in Kb/S or Mb/S etc. + // ToDo: Add check for total % > 100 + // If one child is in %, they must all be + + if ($bwtype != "%") { + $sum = $parent->GetTotalBw(($bw > 0) ? $this : NULL); + + if ($bw > 0) { + $sum += get_bandwidth($bw, $bwtype, $parent); + } + + if ($sum > get_queue_bandwidth($parent)) { + return 1; + } + } foreach ($this->subqueues as $q) { - if ($q->CheckBandwidth(0, '')) + if ($q->CheckBandwidth(0, '')) { return 1; + } } return 0; @@ -1214,7 +1227,7 @@ class priq_queue { } if ($this->CheckBandwidth($data['bandwidth'], $data['bandwidthtype'])) $input_errors[] = "The sum of child bandwidth is higher than parent."; - + if (isset($data['priority']) && (!is_numeric($data['priority']) || ($data['priority'] < 0) || ($data['priority'] > 15))) { $input_errors[] = gettext("The priority must be an integer between 1 and 15.");