/***** FIXME: OLD API BELOW *****/
-/* Return non-zero only if the buffer is empty */
-static inline int buffer_empty(const struct buffer *buf)
-{
- return !b_data(buf);
-}
-
/* Returns non-zero if the buffer's INPUT is considered full, which means that
* it holds at least as much INPUT data as (size - reserve). This also means
* that data that are scheduled for output are considered as potential free
* to wake up as many streams/applets as possible. */
static inline void channel_release_buffer(struct channel *chn, struct buffer_wait *wait)
{
- if (chn->buf->size && buffer_empty(chn->buf)) {
+ if (c_size(chn) && c_empty(chn)) {
b_free(&chn->buf);
offer_buffers(wait->target, tasks_run_queue);
}
static inline void co_skip(struct channel *chn, int len)
{
b_del(chn->buf, len);
- if (buffer_empty(chn->buf))
- chn->buf->p = chn->buf->data;
+ c_realign_if_empty(chn);
/* notify that some data was written to the SI from the buffer */
chn->flags |= CF_WRITE_PARTIAL | CF_WRITE_EVENT;
memcpy(pos, str, len);
b->i += delta;
-
- if (buffer_empty(b))
- b->p = b->data;
+ b_realign_if_empty(b);
return delta;
}
if (unlikely(channel_input_closed(chn)))
return NULL;
- if (!chn->buf->size || !buffer_empty(chn->buf))
+ if (!c_size(chn) || !c_empty(chn))
return buf;
old = chn->buf;
}
}
- /* let's realign the buffer to optimize I/O */
- if (buffer_empty(buf))
- buf->p = buf->data;
+ b_realign_if_empty(buf);
/* read the largest possible block. For this, we perform only one call
* to recv() unless the buffer wraps and we exactly fill the first hunk,
/* a handshake was requested */
return 0;
- /* let's realign the buffer to optimize I/O */
- if (buffer_empty(buf)) {
- buf->p = buf->data;
- }
+ b_realign_if_empty(buf);
/* read the largest possible block. For this, we perform only one call
* to recv() unless the buffer wraps and we exactly fill the first hunk,
{
int offer = 0;
- if (s->req.buf->size && buffer_empty(s->req.buf)) {
+ if (c_size(&s->req) && c_empty(&s->req)) {
offer = 1;
b_free(&s->req.buf);
}
- if (s->res.buf->size && buffer_empty(s->res.buf)) {
+ if (c_size(&s->res) && c_empty(&s->res)) {
offer = 1;
b_free(&s->res.buf);
}