diff --git a/include/haproxy/ring.h b/include/haproxy/ring.h index 307b2887c..201ede465 100644 --- a/include/haproxy/ring.h +++ b/include/haproxy/ring.h @@ -45,12 +45,20 @@ size_t ring_max_payload(const struct ring *ring); int ring_dispatch_messages(struct ring *ring, void *ctx, size_t *ofs_ptr, size_t *last_ofs_ptr, uint flags, ssize_t (*msg_handler)(void *ctx, struct ist v1, struct ist v2, size_t ofs, size_t len)); -/* returns the ring storage's area */ +/* returns the ring storage's usable area */ static inline void *ring_area(const struct ring *ring) { return ring->storage->area; } +/* returns the allocated area for the ring. It covers the whole + * area made of both the ring_storage and the usable area. + */ +static inline void *ring_allocated_area(const struct ring *ring) +{ + return ring->storage; +} + /* returns the number of bytes in the ring */ static inline size_t ring_data(const struct ring *ring) { diff --git a/src/errors.c b/src/errors.c index 1069a69d2..51997da70 100644 --- a/src/errors.c +++ b/src/errors.c @@ -190,7 +190,7 @@ void startup_logs_free(struct ring *r) { #ifdef USE_SHM_OPEN if (r == shm_startup_logs) - munmap(ring_area(r), STARTUP_LOG_SIZE); + munmap(ring_allocated_area(r), STARTUP_LOG_SIZE); #endif /* ! USE_SHM_OPEN */ ring_free(r); } diff --git a/src/sink.c b/src/sink.c index af1a33470..279a0eb95 100644 --- a/src/sink.c +++ b/src/sink.c @@ -695,8 +695,8 @@ static void sink_free(struct sink *sink) return; if (sink->type == SINK_TYPE_BUFFER) { if (sink->store) { - size_t size = (ring_size(sink->ctx.ring) + 4095UL) & -4096UL; - void *area = ring_area(sink->ctx.ring); + size_t size = (ring_allocated_size(sink->ctx.ring) + 4095UL) & -4096UL; + void *area = ring_allocated_area(sink->ctx.ring); msync(area, size, MS_SYNC); munmap(area, size);