From 0ed73c376c8b2dbfe692e86b3bf4aa2310c8d9c2 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 25 May 2022 07:48:07 +0200 Subject: [PATCH] CLEANUP: stconn: rename cs_rx_buff_{blk,rdy} to sc_{need,have}_buff() These functions are used by the application layer to disable or enable reading at the stream connector's level when the input buffer failed to be allocated (or was finally allocated). The new names makes things clearer. --- include/haproxy/conn_stream.h | 14 ++++++++------ include/haproxy/cs_utils.h | 2 +- src/applet.c | 4 ++-- src/stream.c | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/include/haproxy/conn_stream.h b/include/haproxy/conn_stream.h index 8e89cc645..0418039e2 100644 --- a/include/haproxy/conn_stream.h +++ b/include/haproxy/conn_stream.h @@ -344,18 +344,20 @@ static inline void se_need_remote_conn(struct sedesc *se) se_fl_set(se, SE_FL_APPLET_NEED_CONN); } -/* The stream connector just got the input buffer it was waiting for */ -static inline void cs_rx_buff_rdy(struct stconn *cs) +/* The application layer tells the stream connector that it just got the input + * buffer it was waiting for. + */ +static inline void sc_have_buff(struct stconn *cs) { sc_ep_clr(cs, SE_FL_RXBLK_BUFF); } /* The stream connector failed to get an input buffer and is waiting for it. - * Since it indicates a willingness to deliver data to the buffer that will - * have to be retried, we automatically clear RXBLK_ENDP to be called again - * as soon as RXBLK_BUFF is cleared. + * It indicates a willingness to deliver data to the buffer that will have to + * be retried, as such, callers will often automatically clear RXBLK_ENDP to be + * called again as soon as RXBLK_BUFF is cleared. */ -static inline void cs_rx_buff_blk(struct stconn *cs) +static inline void sc_need_buff(struct stconn *cs) { sc_ep_set(cs, SE_FL_RXBLK_BUFF); } diff --git a/include/haproxy/cs_utils.h b/include/haproxy/cs_utils.h index 0da4f43fc..8ec217f2d 100644 --- a/include/haproxy/cs_utils.h +++ b/include/haproxy/cs_utils.h @@ -160,7 +160,7 @@ static inline int cs_alloc_ibuf(struct stconn *cs, struct buffer_wait *wait) ret = channel_alloc_buffer(sc_ic(cs), wait); if (!ret) - cs_rx_buff_blk(cs); + sc_need_buff(cs); return ret; } diff --git a/src/applet.c b/src/applet.c index 718b29902..c48d36f61 100644 --- a/src/applet.c +++ b/src/applet.c @@ -170,7 +170,7 @@ int appctx_buf_available(void *arg) if (!se_fl_test(appctx->sedesc, SE_FL_RXBLK_BUFF)) return 0; - cs_rx_buff_rdy(cs); + sc_have_buff(cs); /* was already allocated another way ? if so, don't take this one */ if (c_size(sc_ic(cs)) || sc_ic(cs)->pipe) @@ -178,7 +178,7 @@ int appctx_buf_available(void *arg) /* allocation possible now ? */ if (!b_alloc(&sc_ic(cs)->buf)) { - cs_rx_buff_blk(cs); + sc_need_buff(cs); return 0; } diff --git a/src/stream.c b/src/stream.c index 1a28900eb..c05f039c7 100644 --- a/src/stream.c +++ b/src/stream.c @@ -315,10 +315,10 @@ int stream_buf_available(void *arg) if (!s->req.buf.size && !s->req.pipe && sc_ep_test(s->scf, SE_FL_RXBLK_BUFF) && b_alloc(&s->req.buf)) - cs_rx_buff_rdy(s->scf); + sc_have_buff(s->scf); else if (!s->res.buf.size && !s->res.pipe && sc_ep_test(s->scb, SE_FL_RXBLK_BUFF) && b_alloc(&s->res.buf)) - cs_rx_buff_rdy(s->scb); + sc_have_buff(s->scb); else return 0;