MINOR: connection: add a flags argument to rcv_buf()

The mux and transport rcv_buf() now takes a "flags" argument, just like
the snd_buf() one or like the equivalent syscall lower part. The upper
layers will use this to pass some information such as indicating whether
the buffer is free from outgoing data or if the lower layer may allocate
the buffer itself.
This commit is contained in:
Willy Tarreau 2018-06-19 06:15:17 +02:00
parent d9cf540457
commit 7f3225f251
7 changed files with 11 additions and 11 deletions

View File

@ -268,7 +268,7 @@ enum {
* and the other ones are used to setup and release the transport layer.
*/
struct xprt_ops {
size_t (*rcv_buf)(struct connection *conn, struct buffer *buf, size_t count); /* recv callback */
size_t (*rcv_buf)(struct connection *conn, struct buffer *buf, size_t count, int flags); /* recv callback */
size_t (*snd_buf)(struct connection *conn, const struct buffer *buf, size_t count, int flags); /* send callback */
int (*rcv_pipe)(struct connection *conn, struct pipe *pipe, unsigned int count); /* recv-to-pipe callback */
int (*snd_pipe)(struct connection *conn, struct pipe *pipe); /* send-to-pipe callback */
@ -297,7 +297,7 @@ struct mux_ops {
void (*send)(struct connection *conn); /* mux-layer send callback */
int (*wake)(struct connection *conn); /* mux-layer callback to report activity, mandatory */
void (*update_poll)(struct conn_stream *cs); /* commit cs flags to mux/conn */
size_t (*rcv_buf)(struct conn_stream *cs, struct buffer *buf, size_t count); /* Called from the upper layer to get data */
size_t (*rcv_buf)(struct conn_stream *cs, struct buffer *buf, size_t count, int flags); /* Called from the upper layer to get data */
size_t (*snd_buf)(struct conn_stream *cs, const struct buffer *buf, size_t count, int flags); /* Called from the upper layer to send data */
int (*rcv_pipe)(struct conn_stream *cs, struct pipe *pipe, unsigned int count); /* recv-to-pipe callback */
int (*snd_pipe)(struct conn_stream *cs, struct pipe *pipe); /* send-to-pipe callback */

View File

@ -824,7 +824,7 @@ static void event_srv_chk_r(struct conn_stream *cs)
done = 0;
conn->mux->rcv_buf(cs, check->bi, check->bi->size);
conn->mux->rcv_buf(cs, check->bi, check->bi->size, 0);
if (conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH) || cs->flags & CS_FL_ERROR) {
done = 1;
if ((conn->flags & CO_FL_ERROR || cs->flags & CS_FL_ERROR) && !check->bi->i) {
@ -2889,7 +2889,7 @@ static int tcpcheck_main(struct check *check)
goto out_end_tcpcheck;
__cs_want_recv(cs);
if (conn->mux->rcv_buf(cs, check->bi, check->bi->size) <= 0) {
if (conn->mux->rcv_buf(cs, check->bi, check->bi->size, 0) <= 0) {
if (conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH) || cs->flags & CS_FL_ERROR) {
done = 1;
if ((conn->flags & CO_FL_ERROR || cs->flags & CS_FL_ERROR) && !check->bi->i) {

View File

@ -2154,7 +2154,7 @@ static void h2_recv(struct connection *conn)
/* note: buf->o == 0 */
max = buf->size - buf->i;
if (max)
conn->xprt->rcv_buf(conn, buf, max);
conn->xprt->rcv_buf(conn, buf, max, 0);
if (!buf->i) {
h2_release_buf(h2c, &h2c->dbuf);
@ -2920,7 +2920,7 @@ static int h2_frt_transfer_data(struct h2s *h2s, struct buffer *buf, int count)
* caller is responsible for never asking for more data than what is available
* in the buffer.
*/
static size_t h2_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t count)
static size_t h2_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
{
struct h2s *h2s = cs->ctx;
struct h2c *h2c = h2s->h2c;

View File

@ -159,11 +159,11 @@ static void mux_pt_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
/*
* Called from the upper layer, to get more data
*/
static size_t mux_pt_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t count)
static size_t mux_pt_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
{
size_t ret;
ret = cs->conn->xprt->rcv_buf(cs->conn, buf, count);
ret = cs->conn->xprt->rcv_buf(cs->conn, buf, count, flags);
if (conn_xprt_read0_pending(cs->conn))
cs->flags |= CS_FL_EOS;
if (cs->conn->flags & CO_FL_ERROR)

View File

@ -250,7 +250,7 @@ int raw_sock_from_pipe(struct connection *conn, struct pipe *pipe)
* errno is cleared before starting so that the caller knows that if it spots an
* error without errno, it's pending and can be retrieved via getsockopt(SO_ERROR).
*/
static size_t raw_sock_to_buf(struct connection *conn, struct buffer *buf, size_t count)
static size_t raw_sock_to_buf(struct connection *conn, struct buffer *buf, size_t count, int flags)
{
ssize_t ret;
size_t try, done = 0;

View File

@ -5337,7 +5337,7 @@ reneg_ok:
* avoiding the call if inappropriate. The function does not call the
* connection's polling update function, so the caller is responsible for this.
*/
static size_t ssl_sock_to_buf(struct connection *conn, struct buffer *buf, size_t count)
static size_t ssl_sock_to_buf(struct connection *conn, struct buffer *buf, size_t count, int flags)
{
ssize_t ret;
size_t try, done = 0;

View File

@ -1189,7 +1189,7 @@ static void si_cs_recv_cb(struct conn_stream *cs)
break;
}
ret = conn->mux->rcv_buf(cs, ic->buf, max);
ret = conn->mux->rcv_buf(cs, ic->buf, max, 0);
if (cs->flags & CS_FL_RCV_MORE)
si->flags |= SI_FL_WAIT_ROOM;