MEDIUM: ring: replace the buffer API in ring_write() with the vec<->ring API
authorWilly Tarreau <w@1wt.eu>
Mon, 26 Feb 2024 10:03:03 +0000 (11:03 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 Mar 2024 17:34:19 +0000 (17:34 +0000)
commit4e6fadb8a18c0de107a8ed4420f15afd94c9f7ce
tree10fc2e1111c2dbb946046ba4cb0167d6972d8f3d
parent4e6de42b27a60f6bf3d747237a3573ce7c3a45e1
MEDIUM: ring: replace the buffer API in ring_write() with the vec<->ring API

This is the start of the replacement of the buffer API calls. Only the
ring_write() function was touched. Instead of manipulating a buffer all
along, we now extract the ring buffer's head and tail upon entry, store
them locally and use them using the vec<->ring API until the last moment
where we can update the buffer with the new values. One subtle point is
that we must never fill the buffer past the last byte otherwise the
vec-to-ring conversion gets lost and there's no more possibility to know
where's the beginning nor the end (just like when dealing with head+tail
in fact), because it then becomes impossible to distinguish between an
empty and a full buffer.
src/ring.c