In ring_resize() we used to check if the new ring was at least as large
as the previous one before resizing it, but what counts is that it's as
large as the previous one's contents. Initially it was thought this
would not really matter, but given that rings are initially created as
BUFSIZE, it's currently not possible to shrink them for debugging
purposes. Now with this change it is.
{
struct ring_storage *new;
- if (size <= ring_size(ring) + sizeof(*ring->storage))
+ if (size <= ring_data(ring) + sizeof(*ring->storage))
return ring;
new = malloc(size);
thread_isolate();
- /* recheck the buffer's size, it may have changed during the malloc */
-
- if (size > ring_size(ring) + sizeof(*ring->storage)) {
+ /* recheck the ring's size, it may have changed during the malloc */
+ if (size > ring_data(ring) + sizeof(*ring->storage)) {
/* copy old contents */
new->buf = b_make(new->area, size - sizeof(*ring->storage), 0, 0);
b_getblk(&ring->storage->buf, new->area, ring_data(ring), 0);
goto err;
}
- if (size < ring_size(cfg_sink->ctx.ring)) {
- ha_warning("parsing [%s:%d] : ignoring new size '%llu' that is smaller than current size '%llu' for ring '%s'.\n",
- file, linenum, (ullong)size, (ullong)ring_size(cfg_sink->ctx.ring), cfg_sink->name);
+ if (size < ring_data(cfg_sink->ctx.ring)) {
+ ha_warning("parsing [%s:%d] : ignoring new size '%llu' that is smaller than contents '%llu' for ring '%s'.\n",
+ file, linenum, (ullong)size, (ullong)ring_data(cfg_sink->ctx.ring), cfg_sink->name);
err_code |= ERR_WARN;
goto err;
}