From d9cf540457342d1a14722a9f3212eceab3847349 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 18 Jul 2018 11:29:06 +0200 Subject: [PATCH] MEDIUM: mux: make mux->rcv_buf() take a size_t for the count 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 | 2 +- src/mux_h2.c | 4 ++-- src/mux_pt.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/types/connection.h b/include/types/connection.h index 69d73948a..18c2eb048 100644 --- a/include/types/connection.h +++ b/include/types/connection.h @@ -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 */ diff --git a/src/mux_h2.c b/src/mux_h2.c index 4a39b5104..2895839cc 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -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 diff --git a/src/mux_pt.c b/src/mux_pt.c index d65c4e202..aa03fd415 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -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 */