From 3335365b0903d2b1baf7331d17203490cdee65ea Mon Sep 17 00:00:00 2001 From: xchaos Date: Tue, 20 Oct 2015 01:36:27 +0000 Subject: [PATCH] ehm git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@253 251d49ef-1d17-4917-a970-b30cf55b089b --- prometheus.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/prometheus.c b/prometheus.c index c7f8013..a243c16 100644 --- a/prometheus.c +++ b/prometheus.c @@ -1051,20 +1051,20 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); ptr++; if_exists(ip,ips,eq(ip->addr,_)) { - int unshape_this_ip = stop_shaping; + int unshape_this_ip; long avg_mbps_down = ip->traffic_down * 8 / how_much_seconds; long avg_mbps_up = ip->traffic_up * 8 / how_much_seconds; - int min_mbps = ip->min>>10; int agreg = 1, print_stats = 1; - if(min_mbps < 1) - { - min_mbps = 1; - } - if(ip->keyword->download_aggregation) { - if(min_mbps/ip->keyword->download_aggregation <= avg_mbps_down) + int min_mbps = (ip->min/ip->keyword->download_aggregation)>>10; + if(min_mbps < 1) + { + min_mbps = 1; + } + + if(min_mbps <= avg_mbps_down) { unshape_this_ip = 0; agreg = (int)((float)(avg_mbps_down+1)/min_mbps+.5); @@ -1079,7 +1079,13 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); } else if(ip->keyword->upload_aggregation) { - if(min_mbps/ip->keyword->upload_aggregation <= avg_mbps_up) + int min_mbps = (ip->min/ip->keyword->upload_aggregation)>>10; + if(min_mbps < 1) + { + min_mbps = 1; + } + + if(min_mbps <= avg_mbps_up) { unshape_this_ip = 0; agreg = (int)((float)(avg_mbps_up+1)/min_mbps+.5); @@ -1091,6 +1097,10 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); unshape_this_ip = 1; } } + if(stop_shaping) + { + unshape_this_ip = 1; + } ip->aggregated = agreg; ip->mark = atoi(ptr); if(ip->max < ip->desired || unshape_this_ip || reduce_ceil) /* apply or disable FUP limit immediately.... */ -- 2.30.2