Re: Incorrect change in cache_cf.c

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Thu, 17 Oct 2002 04:27:19 +0200

Thanks for the clarification. Reverted to how it was before and
removed bug+patch from the bugs page.

Regards
Henrik

Regards
Henrik

On Wednesday 16 October 2002 12.31, David Luyer wrote:
> --- squid/src/cache_cf.c:1.396.2.7 Sat Sep 7 09:13:59 2002
> +++ squid/src/cache_cf.c Mon Oct 14 02:18:27 2002
> @@ -828,7 +830,7 @@
> delayFreeDelayPool(pool);
> safe_free(cfg->rates[pool]);
> }
> - cfg->rates[pool] = xmalloc(class * sizeof(delaySpec));
> + cfg->rates[pool] = xmalloc(class * sizeof(delaySpecSet));
> cfg->class[pool] = class;
> cfg->rates[pool]->aggregate.restore_bps =
> cfg->rates[pool]->aggregate.max_bytes = -1;
> if (cfg->class[pool] >= 3)
>
> This change is wrong.
>
> It should be fine as it was before (class * sizeof(delaySpec)) but
> if someone really insists on changing it, it should be changed
> to (sizeof(delaySpecSet)) without the multiplier and the relevent
> comments updated (delay_pools.c, structs.h, etc).
>
> See this comment in structs.h for more clarity:
>
> (structs.h... missing closing bracket on this comment)
> /* malloc()'d only as far as used (class * sizeof(delaySpec)!
> * order of elements very important!
> */
> struct _delaySpecSet {
> delaySpec aggregate;
> delaySpec individual;
> delaySpec network;
> };
>
> (delay_pools.c - this and similar comments contained many times)
> /* delaySetSpec may be pointer to partial structure so MUST
> pass by * reference.
> */
>
> aggregate is class 1 and has only the first delaySpec completed.
> individual is class 2 and has the two delaySpecs completed.
> network is class 3 and has all three delaySpecs.
>
> This is _always_ passed by reference, and is only malloc()d as much
> memory as is required for the elements it contains. It's the same
> as the union delayPool which is malloc()d only for the current
> structure it contains.
>
> David.
Received on Wed Oct 16 2002 - 20:28:04 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:16:56 MST