MINOR: buffer: remove bo_contig_data()

The two call places now make use of b_contig_data(0) and check by
themselves that the returned size is no larger than the scheduled
output data.
This commit is contained in:
Willy Tarreau 2018-06-07 19:03:40 +02:00
parent 8f9c72d301
commit 0e11d59af6
3 changed files with 7 additions and 12 deletions

View File

@ -105,16 +105,6 @@ static inline void bo_del(struct buffer *b, unsigned int del)
b->o -= del;
}
/* Returns the amount of output data that can contiguously be read at once */
static inline int bo_contig_data(const struct buffer *b)
{
char *beg = b->p - b->o;
if (beg < b->data)
return b->data - beg;
return b->o;
}
/* Return the amount of bytes that can be written into the input area at once
* including reserved space which may be overwritten (this is the caller
* responsibility to know if the reserved space is protected or not).

View File

@ -720,7 +720,10 @@ http_compression_buffer_end(struct comp_state *st, struct stream *s,
/* Copy previous data from ib->o into ob->o */
if (ib->o > 0) {
left = bo_contig_data(ib);
left = b_contig_data(ib, 0);
if (left > ib->o)
left = ib->o;
memcpy(ob->p - ob->o, b_head(ib), left);
if (ib->o - left) /* second part of the buffer */
memcpy(ob->p - ob->o + left, ib->data, ib->o - left);

View File

@ -5526,7 +5526,9 @@ static int ssl_sock_from_buf(struct connection *conn, struct buffer *buf, int fl
size_t written_data;
#endif
try = bo_contig_data(buf);
try = b_contig_data(buf, 0);
if (try > buf->o)
try = buf->o;
if (!(flags & CO_SFL_STREAMER) &&
!(conn->xprt_st & SSL_SOCK_SEND_UNLIMITED) &&