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.
This commit is contained in:
Willy Tarreau 2012-05-18 22:11:27 +02:00
parent be0688c64d
commit 13e66dad26

View File

@ -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 <adv> 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 <res>, which is
* preserved.