Re: cvs commit: squid/src stat.c tools.c

From: Duane Wessels <wessels@dont-contact.us>
Date: Fri, 3 Nov 2006 17:03:37 -0700 (MST)

On Thu, 2 Nov 2006, Henrik Nordstrom wrote:

> ons 2006-11-01 klockan 13:58 -0700 skrev Duane Wessels:
>
>> struct kb_t uses squid_off_t, which might be signed. That means that
>> kb_t.kb could overflow and become negative in kb_incr(). If we detect
>> that it is negative, add increasing powers of two until the value becomes
>> positive again. This should work if squid_off_t is 32 ot 64 bits.
>
> Duane. can you explain the reasoning behind this? Gut feeling is that
> this may actually cause more headaches with a counter bouncing around
> unpredictable like this.

The reasoning is that when Squid reports bandwidth as negative, it
really screws up bandwidth graphs.

I think it would be better if the counter were guaranteed to
be unsigned, but squid_off_t is signed on some systems at least.
I believe in squid-3 the use of size_t means it will always be
unsigned.

I don't know why you say "bouncing around." With the patch it
should overflow properly, as though the counter were 2^31
bits (or 2^63 I suppose).

I considered just setting the counter to zero if it became
negative, but I thought it would be nice to preserve the
amount carried over after the overflow, if possible.

Duane W.
Received on Fri Nov 03 2006 - 17:03:38 MST

This archive was generated by hypermail pre-2.1.9 : Wed Nov 29 2006 - 12:00:05 MST