]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: connections: Make rcv_buf mandatory and nuke cs_recv().
authorOlivier Houchard <ohouchard@haproxy.com>
Thu, 16 Aug 2018 13:30:32 +0000 (15:30 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 16 Aug 2018 15:23:44 +0000 (17:23 +0200)
Reintroduce h2_rcv_buf(), right now it just does what cs_recv() did, but
should be modified later.

include/proto/connection.h
src/checks.c
src/connection.c
src/mux_h2.c
src/stream_interface.c

index 8261d57602d8478969dd19e2e7e0df4f2e6fe7f5..33ccc0be1485075e8d839fd06b27d52c0aa4eee1 100644 (file)
@@ -304,17 +304,6 @@ static inline void cs_update_mux_polling(struct conn_stream *cs)
                conn->mux->update_poll(cs);
 }
 
-/* conn_stream receive function. Uses mux->rcv_buf() if defined, otherwise
- * falls back to __cs_recv().
- */
-static inline size_t cs_recv(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
-{
-       if (cs->conn->mux->rcv_buf)
-               return cs->conn->mux->rcv_buf(cs, buf, count, flags);
-       else
-               return __cs_recv(cs, buf, count, flags);
-}
-
 /* conn_stream send function. Uses mux->snd_buf() if defined, otherwise
  * falls back to __cs_send().
  */
index ef7237a9f39e7a59f1a449a318f54b0416e4e389..bb50548a1afda3bd47720c09864ce89961ce382b 100644 (file)
@@ -850,7 +850,7 @@ static void event_srv_chk_r(struct conn_stream *cs)
 
        done = 0;
 
-       cs_recv(cs, &check->bi, b_size(&check->bi), 0);
+       cs->conn->mux->rcv_buf(cs, &check->bi, b_size(&check->bi), 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) && !b_data(&check->bi)) {
@@ -2917,7 +2917,7 @@ static int tcpcheck_main(struct check *check)
                                goto out_end_tcpcheck;
 
                        __cs_want_recv(cs);
-                       if (cs_recv(cs, &check->bi, b_size(&check->bi), 0) <= 0) {
+                       if (cs->conn->mux->rcv_buf(cs, &check->bi, b_size(&check->bi), 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) && !b_data(&check->bi)) {
index f750e3c99ba37a35e897b4c03013c8a2be03bff3..2a7fb1b478ebd094a190c4729301e44ec528a51e 100644 (file)
@@ -383,33 +383,6 @@ int conn_sock_drain(struct connection *conn)
        return 1;
 }
 
-/*
- * default conn_stream recv() : this one is used when cs->rcv_buf == NULL.
- * It reads up to <count> bytes from cs->rxbuf, puts them into <buf> and
- * returns the count. It possibly sets/clears CS_FL_RCV_MORE depending on the
- * buffer's state, and may set CS_FL_EOS. The number of bytes transferred is
- * returned. <buf> is not touched if <count> is null, but cs flags will be
- * updated to indicate any RCV_MORE or EOS.
- */
-size_t __cs_recv(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
-{
-       size_t ret = 0;
-
-       /* transfer possibly pending data to the upper layer */
-       ret = b_xfer(buf, &cs->rxbuf, count);
-
-       if (b_data(&cs->rxbuf))
-               cs->flags |= CS_FL_RCV_MORE;
-       else {
-               cs->flags &= ~CS_FL_RCV_MORE;
-               if (cs->flags & CS_FL_REOS)
-                       cs->flags |= CS_FL_EOS;
-               cs_drop_rxbuf(cs);
-       }
-
-       return ret;
-}
-
 /*
  * default cs send() : this one is used when mux->snd_buf == NULL. It puts up to
  * <count> bytes from <buf> into cs->txbuf. The number of bytes transferred is
index a986b5a932af2e94b982865829e8abe8915915bd..cb6ea26917cab7d0960add34301380601c2c9832 100644 (file)
@@ -3414,6 +3414,26 @@ static int h2_subscribe(struct conn_stream *cs, int event_type, void *param)
 
 }
 
+/* Called from the upper layer, to receive data */
+static size_t h2_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
+{
+       size_t ret = 0;
+
+       /* transfer possibly pending data to the upper layer */
+       ret = b_xfer(buf, &cs->rxbuf, count);
+
+       if (b_data(&cs->rxbuf))
+               cs->flags |= CS_FL_RCV_MORE;
+       else {
+               cs->flags &= ~CS_FL_RCV_MORE;
+               if (cs->flags & CS_FL_REOS)
+                       cs->flags |= CS_FL_EOS;
+               cs_drop_rxbuf(cs);
+       }
+
+       return ret;
+}
+
 /* Called from the upper layer, to send data */
 static size_t h2_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
 {
@@ -3591,6 +3611,7 @@ const struct mux_ops h2_ops = {
        .wake = h2_wake,
        .update_poll = h2_update_poll,
        .snd_buf = h2_snd_buf,
+       .rcv_buf = h2_rcv_buf,
        .subscribe = h2_subscribe,
        .attach = h2_attach,
        .detach = h2_detach,
index e56a7c135e5237394d50d9bc64bab3b6910eee65..591d8352b0d7b6fe7785379bdd506f0c7143dad2 100644 (file)
@@ -1244,7 +1244,7 @@ static void si_cs_recv_cb(struct conn_stream *cs)
                        break;
                }
 
-               ret = cs_recv(cs, &ic->buf, max, co_data(ic) ? CO_RFL_BUF_WET : 0);
+               ret = cs->conn->mux->rcv_buf(cs, &ic->buf, max, co_data(ic) ? CO_RFL_BUF_WET : 0);
                if (cs->flags & CS_FL_RCV_MORE)
                        si->flags |= SI_FL_WAIT_ROOM;