Rainer Klier wrote:
> Max: 50000000
> Restore: 578
> Current: -17946782
> ----------------------------
>
> Even a restart of squid resulted in about -17 million
> buckets. Is this a bug ?
It is a misfeature. max * initial_level must be less than 2^31, or the
integer maths will overflow.
Please try the attached patch.
-- Henrik Nordstrom Spare time Squid hacker
Index: squid/src/delay_pools.c
diff -u squid/src/delay_pools.c:1.1.1.8.4.2 squid/src/delay_pools.c:1.1.1.8.4.3
--- squid/src/delay_pools.c:1.1.1.8.4.2 Wed May 5 11:33:50 1999
+++ squid/src/delay_pools.c Wed May 19 23:01:48 1999
@@ -211,18 +211,18 @@
*/
switch (class) {
case 1:
- delay_data[pool].class1->aggregate = (rates->aggregate.max_bytes *
- Config.Delay.initial) / 100;
+ delay_data[pool].class1->aggregate = (int)(((double)rates->aggregate.max_bytes *
+ Config.Delay.initial) / 100);
break;
case 2:
- delay_data[pool].class2->aggregate = (rates->aggregate.max_bytes *
- Config.Delay.initial) / 100;
+ delay_data[pool].class2->aggregate = (int)(((double)rates->aggregate.max_bytes *
+ Config.Delay.initial) / 100);
delay_data[pool].class2->individual_map[0] = 255;
delay_data[pool].class2->individual_255_used = 0;
break;
case 3:
- delay_data[pool].class3->aggregate = (rates->aggregate.max_bytes *
- Config.Delay.initial) / 100;
+ delay_data[pool].class3->aggregate = (int)(((double)rates->aggregate.max_bytes *
+ Config.Delay.initial) / 100);
delay_data[pool].class3->network_map[0] = 255;
delay_data[pool].class3->network_255_used = 0;
memset(&delay_data[pool].class3->individual_255_used, '\0',
@@ -296,8 +296,8 @@
if (!delay_data[pool].class2->individual_255_used) {
delay_data[pool].class2->individual_255_used = 1;
delay_data[pool].class2->individual[255] =
- (Config.Delay.rates[pool]->individual.max_bytes *
- Config.Delay.initial) / 100;
+ (int)(((double)Config.Delay.rates[pool]->individual.max_bytes *
+ Config.Delay.initial) / 100);
}
return delayId(pool + 1, 255);
}
@@ -308,8 +308,8 @@
delay_data[pool].class2->individual_map[i] = host;
delay_data[pool].class2->individual_map[i + 1] = 255;
delay_data[pool].class2->individual[i] =
- (Config.Delay.rates[pool]->individual.max_bytes *
- Config.Delay.initial) / 100;
+ (int)(((double)Config.Delay.rates[pool]->individual.max_bytes *
+ Config.Delay.initial) / 100);
break;
}
}
@@ -324,8 +324,8 @@
if (!delay_data[pool].class3->network_255_used) {
delay_data[pool].class3->network_255_used = 1;
delay_data[pool].class3->network[255] =
- (Config.Delay.rates[pool]->network.max_bytes *
- Config.Delay.initial) / 100;
+ (int)(((double)Config.Delay.rates[pool]->network.max_bytes *
+ Config.Delay.initial) / 100);
}
} else {
for (i = 0;; i++) {
@@ -336,8 +336,8 @@
delay_data[pool].class3->individual_map[i][0] = 255;
delay_data[pool].class3->network_map[i + 1] = 255;
delay_data[pool].class3->network[i] =
- (Config.Delay.rates[pool]->network.max_bytes *
- Config.Delay.initial) / 100;
+ (int)(((double)Config.Delay.rates[pool]->network.max_bytes *
+ Config.Delay.initial) / 100);
break;
}
}
@@ -348,8 +348,8 @@
if (!(delay_data[pool].class3->individual_255_used[i / 8] & (1 << (i % 8)))) {
delay_data[pool].class3->individual_255_used[i / 8] |= (1 << (i % 8));
delay_data[pool].class3->individual[position] =
- (Config.Delay.rates[pool]->individual.max_bytes *
- Config.Delay.initial) / 100;
+ (int)(((double)Config.Delay.rates[pool]->individual.max_bytes *
+ Config.Delay.initial) / 100);
}
return delayId(pool + 1, position);
}
@@ -362,8 +362,8 @@
delay_data[pool].class3->individual_map[i][j] = host;
delay_data[pool].class3->individual_map[i][j + 1] = 255;
delay_data[pool].class3->individual[position |= j] =
- (Config.Delay.rates[pool]->individual.max_bytes *
- Config.Delay.initial) / 100;
+ (int)(((double)Config.Delay.rates[pool]->individual.max_bytes *
+ Config.Delay.initial) / 100);
break;
}
}
Received on Wed May 19 1999 - 15:06:03 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:46:20 MST