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

2006-11-03 Thread Duane Wessels




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.


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

2006-11-01 Thread Henrik Nordstrom
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.

Did not see any discussion about this either on squid-dev or bugzilla.

Regards
Henrik


signature.asc
Description: Detta är en digitalt signerad	meddelandedel