From: Christopher Faulet Date: Fri, 1 Apr 2022 15:19:36 +0000 (+0200) Subject: MINOR: stream-int/conn-stream: Move si_alloc_ibuf() in the conn-stream scope X-Git-Tag: v2.6-dev6~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8f45eec016ce882eeb54b760dd63565541ce169d;p=thirdparty%2Fhaproxy.git MINOR: stream-int/conn-stream: Move si_alloc_ibuf() in the conn-stream scope si_alloc_ibuf() is renamed as c_alloc_ibuf() and update to manipulate a conn-stream instead of a stream-interface. --- diff --git a/include/haproxy/cs_utils.h b/include/haproxy/cs_utils.h index 257fcd3af2..573be47c29 100644 --- a/include/haproxy/cs_utils.h +++ b/include/haproxy/cs_utils.h @@ -141,6 +141,24 @@ static inline int cs_is_conn_error(const struct conn_stream *cs) return !!(conn->flags & CO_FL_ERROR); } +/* Try to allocate a buffer for the conn-stream's input channel. It relies on + * channel_alloc_buffer() for this so it abides by its rules. It returns 0 on + * failure, non-zero otherwise. If no buffer is available, the requester, + * represented by the pointer, will be added in the list of objects + * waiting for an available buffer, and SI_FL_RXBLK_BUFF will be set on the + * stream-int and SI_FL_RX_WAIT_EP cleared. The requester will be responsible + * for calling this function to try again once woken up. + */ +static inline int cs_alloc_ibuf(struct conn_stream *cs, struct buffer_wait *wait) +{ + int ret; + + ret = channel_alloc_buffer(cs_ic(cs), wait); + if (!ret) + si_rx_buff_blk(cs->si); + return ret; +} + /* Returns the source address of the conn-stream and, if not set, fallbacks on * the session for frontend CS and the server connection for the backend CS. It diff --git a/include/haproxy/stream_interface.h b/include/haproxy/stream_interface.h index 5c6436705f..655e30a1c6 100644 --- a/include/haproxy/stream_interface.h +++ b/include/haproxy/stream_interface.h @@ -243,24 +243,6 @@ static inline void si_done_get(struct stream_interface *si) si->flags &= ~(SI_FL_WANT_GET | SI_FL_WAIT_DATA); } -/* Try to allocate a buffer for the stream-int's input channel. It relies on - * channel_alloc_buffer() for this so it abides by its rules. It returns 0 on - * failure, non-zero otherwise. If no buffer is available, the requester, - * represented by the pointer, will be added in the list of objects - * waiting for an available buffer, and SI_FL_RXBLK_BUFF will be set on the - * stream-int and SI_FL_RX_WAIT_EP cleared. The requester will be responsible - * for calling this function to try again once woken up. - */ -static inline int si_alloc_ibuf(struct stream_interface *si, struct buffer_wait *wait) -{ - int ret; - - ret = channel_alloc_buffer(si_ic(si), wait); - if (!ret) - si_rx_buff_blk(si); - return ret; -} - #endif /* _HAPROXY_STREAM_INTERFACE_H */ /* diff --git a/src/applet.c b/src/applet.c index b403c239e8..21da1a485e 100644 --- a/src/applet.c +++ b/src/applet.c @@ -150,7 +150,7 @@ struct task *task_run_applet(struct task *t, void *context, unsigned int state) * some other processing if needed. The applet doesn't have anything to * do if it needs the buffer, it will be called again upon readiness. */ - if (!si_alloc_ibuf(cs->si, &app->buffer_wait)) + if (!cs_alloc_ibuf(cs, &app->buffer_wait)) si_rx_endp_more(cs->si); count = co_data(cs_oc(cs)); diff --git a/src/hlua.c b/src/hlua.c index fa0a211df1..d39732c023 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -2366,7 +2366,7 @@ static int hlua_socket_write_yield(struct lua_State *L,int status, lua_KContext * the request buffer if its not required. */ if (s->req.buf.size == 0) { - if (!si_alloc_ibuf(cs->si, &appctx->buffer_wait)) + if (!cs_alloc_ibuf(cs, &appctx->buffer_wait)) goto hlua_socket_write_yield_return; } diff --git a/src/stream_interface.c b/src/stream_interface.c index 85c9398ffb..573b072532 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -655,7 +655,7 @@ int cs_conn_recv(struct conn_stream *cs) } /* now we'll need a input buffer for the stream */ - if (!si_alloc_ibuf(cs->si, &(__cs_strm(cs)->buffer_wait))) + if (!cs_alloc_ibuf(cs, &(__cs_strm(cs)->buffer_wait))) goto end_recv; /* For an HTX stream, if the buffer is stuck (no output data with some