]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: mux: make mux->rcv_buf() take a size_t for the count
authorWilly Tarreau <w@1wt.eu>
Wed, 18 Jul 2018 09:29:06 +0000 (11:29 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 Jul 2018 14:23:41 +0000 (16:23 +0200)
It also returns a size_t. This is in order to clean the API. Note
that the H2 mux still uses some ints in the functions called from
h2_rcv_buf(), though it's not really a problem given that H2 frames
are smaller. It may deserve a general cleanup later though.

include/types/connection.h
src/mux_h2.c
src/mux_pt.c

index 69d73948ac070223182811e2f948da53963486d1..18c2eb048a2020e1f5b9096002f0bc6c82ac03ad 100644 (file)
@@ -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 */
-       int  (*rcv_buf)(struct conn_stream *cs, struct buffer *buf, int count); /* Called from the upper layer to get data */
+       size_t (*rcv_buf)(struct conn_stream *cs, struct buffer *buf, size_t count); /* 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 4a39b51044919c06cbe4c54b01a0630380daebff..2895839cc140f9eb27d76264c2ca28bb3284f15f 100644 (file)
@@ -2920,11 +2920,11 @@ 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 int h2_rcv_buf(struct conn_stream *cs, struct buffer *buf, int count)
+static size_t h2_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t count)
 {
        struct h2s *h2s = cs->ctx;
        struct h2c *h2c = h2s->h2c;
-       int ret = 0;
+       size_t ret = 0;
 
        if (h2c->st0 != H2_CS_FRAME_P)
                return 0; // no pre-parsed frame yet
index d65c4e2024ff728d8fc7a8aac5d7a71ee9bc5e2b..aa03fd415598b54c867c018bcbedd5aaf69927ec 100644 (file)
@@ -159,16 +159,16 @@ static void mux_pt_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
 /*
  * Called from the upper layer, to get more data
  */
-static int mux_pt_rcv_buf(struct conn_stream *cs, struct buffer *buf, int count)
+static size_t mux_pt_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t count)
 {
-       int ret;
+       size_t ret;
 
        ret = cs->conn->xprt->rcv_buf(cs->conn, buf, count);
        if (conn_xprt_read0_pending(cs->conn))
                cs->flags |= CS_FL_EOS;
        if (cs->conn->flags & CO_FL_ERROR)
                cs->flags |= CS_FL_ERROR;
-       return (ret);
+       return ret;
 }
 
 /* Called from the upper layer, to send data */