From 7f3225f2512f4b7e212212705ec5caecb5c7be74 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 19 Jun 2018 06:15:17 +0200 Subject: [PATCH] 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. --- include/types/connection.h | 4 ++-- src/checks.c | 4 ++-- src/mux_h2.c | 4 ++-- src/mux_pt.c | 4 ++-- src/raw_sock.c | 2 +- src/ssl_sock.c | 2 +- src/stream_interface.c | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/types/connection.h b/include/types/connection.h index 18c2eb048..13cbf7300 100644 --- a/include/types/connection.h +++ b/include/types/connection.h @@ -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 */ diff --git a/src/checks.c b/src/checks.c index 9cbc5de58..a499f23fa 100644 --- a/src/checks.c +++ b/src/checks.c @@ -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) { diff --git a/src/mux_h2.c b/src/mux_h2.c index 2895839cc..250eae210 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -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; diff --git a/src/mux_pt.c b/src/mux_pt.c index aa03fd415..b6d0b1aad 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -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) diff --git a/src/raw_sock.c b/src/raw_sock.c index daf3d0701..477862eda 100644 --- a/src/raw_sock.c +++ b/src/raw_sock.c @@ -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; diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 20b7cdfca..42cb72fb4 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -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; diff --git a/src/stream_interface.c b/src/stream_interface.c index 4a095d8da..0afcb972c 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -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;