From 13e66dad264e26e19f2f36037bafae8dee304c18 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 18 May 2012 22:11:27 +0200 Subject: [PATCH] MINOR: buffers: add a rewind function b_rew() will be used to rewind a buffer for certain specific operations such as header inspection on data already in the output queue. --- include/proto/buffers.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/proto/buffers.h b/include/proto/buffers.h index 6f8e2c15d4..66c6e61782 100644 --- a/include/proto/buffers.h +++ b/include/proto/buffers.h @@ -303,6 +303,19 @@ static inline void b_adv(struct buffer *b, unsigned int adv) b->p = b_ptr(b, adv); } +/* Rewinds the buffer by bytes, which means that the buffer pointer goes + * backwards, and that as many bytes from out are moved to in. The caller is + * responsible for ensuring that adv is always smaller than or equal to b->o. + */ +static inline void b_rew(struct buffer *b, unsigned int adv) +{ + b->i += adv; + b->o -= adv; + if (!b->o && !b->pipe) + b->flags |= BF_OUT_EMPTY; + b->p = b_ptr(b, -adv); +} + /* Return the amount of bytes that can be written into the buffer at once, * excluding the amount of reserved space passed in , which is * preserved. -- 2.39.5