mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-01-11 03:41:00 +01:00
The buffers API defines both a storage layout and how to handle the data. The storage is shared with the chunks API which only deals with non-wrapping messages while buffers support wrapping both of the data and of the free space. As such, most of the buffers code already makes special cases of two parts in a buffer, the first one before wrapping and the optional second one after the wrapping occurred. The thing is, there are plenty of other places (e.g. rings) where the code dealing with wrapping is desirable but with a different storage layout. Let's export the existing buffer handling code related to reading/writing wrapping data and make it work with arbitrary vector pairs instead. This will handle wrapping and holes in messages if desired, and it will be up to the caller to decide how its messages are arranged and to pass the relevant ptr,len elements. The code is limited to two vectors because this is sufficient to deal with wrapping without making the code needlessly complex. I.e. this will not reassemble an iovec. For vectors, since we already had the ist type, there's no point inventing a new type, and it's even possible that over time some callers will find benefits in using this unified API (i.e. no NOP translation layer). It also allows to pass inputs as direct arguments and outputs as pointers. Not only this is more efficient code-wise, but it also avoids the accidental use of a wrong function. It was indeed found that naming functions is even harder than with the buffer as the notion of from/to is even fuzzier here. The API will likely continue to evolve and some functions might get renamed to more explicit ones over time to limit confusion. For now the code provides anything needed to reset/create/fill/erase/read/peek or measure vector pairs and to manipulate chars/blocks/varints to/from there.