From 0e11d59af6660d379a0967b07bfe8d23d335f844 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 7 Jun 2018 19:03:40 +0200 Subject: [PATCH] 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. --- include/common/buffer.h | 10 ---------- src/flt_http_comp.c | 5 ++++- src/ssl_sock.c | 4 +++- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/include/common/buffer.h b/include/common/buffer.h index 0c8eeb0199..8638bd6849 100644 --- a/include/common/buffer.h +++ b/include/common/buffer.h @@ -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). diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c index 0ccf23b122..99b18cc4f7 100644 --- a/src/flt_http_comp.c +++ b/src/flt_http_comp.c @@ -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); diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 56d2eed7fa..e694c8721e 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -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) && -- 2.47.3