]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: connection: add a flags argument to rcv_buf()
authorWilly Tarreau <w@1wt.eu>
Tue, 19 Jun 2018 04:15:17 +0000 (06:15 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 Jul 2018 14:23:41 +0000 (16:23 +0200)
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
src/checks.c
src/mux_h2.c
src/mux_pt.c
src/raw_sock.c
src/ssl_sock.c
src/stream_interface.c

index 18c2eb048a2020e1f5b9096002f0bc6c82ac03ad..13cbf7300fd354f676f308511b9785a3c67b1d4f 100644 (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 */
index 9cbc5de58d2e2e1581a0f9afbe359c8a914d8583..a499f23fa213ec46f68310b55e8b0cebb86c96e8 100644 (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) {
index 2895839cc140f9eb27d76264c2ca28bb3284f15f..250eae210cec7832ff717907969de1b12838c3cb 100644 (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;
index aa03fd415598b54c867c018bcbedd5aaf69927ec..b6d0b1aadfbb0ed3226c8a292c27e24d9a485552 100644 (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)
index daf3d0701c5196f16803fec5b02cfeea6f230177..477862eda4cc40d3f10bfc00bcc912f27af28f64 100644 (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;
index 20b7cdfca0acaab05927e5697ca6b3d903ac898a..42cb72fb49a797d853b61a77ee700c9fcb764206 100644 (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;
index 4a095d8dae6f563c2b6de1dee093afdcbf9a1b95..0afcb972cd8a9efd3fd698f9df5e10f3c84be5bd 100644 (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;