]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream-int/conn-stream: Move si_alloc_ibuf() in the conn-stream scope
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 1 Apr 2022 15:19:36 +0000 (17:19 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 13 Apr 2022 13:10:15 +0000 (15:10 +0200)
si_alloc_ibuf() is renamed as c_alloc_ibuf() and update to manipulate a
conn-stream instead of a stream-interface.

include/haproxy/cs_utils.h
include/haproxy/stream_interface.h
src/applet.c
src/hlua.c
src/stream_interface.c

index 257fcd3af297fe4d2a2d8e5c639c5f35f171bc63..573be47c294d91495e56468c858c7314cbd569fc 100644 (file)
@@ -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 <wait> 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
index 5c6436705f9c670132f80b4673a12bd4ad6ba9d8..655e30a1c623424912839f812f6ad85cc3b98f22 100644 (file)
@@ -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 <wait> 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 */
 
 /*
index b403c239e84fe66b4236149ea3f02d0be66a9275..21da1a485ee2f5006e2c0f41a611e35177c9e28f 100644 (file)
@@ -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));
index fa0a211df11eb05fc8c7ae3e345b04292b3117ea..d39732c02311f13abf63363bb5567ebefa1da8c6 100644 (file)
@@ -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;
        }
 
index 85c9398ffb929cc18bdde57e85f1458db0ee7f1a..573b072532ddd020f2a47e83ad22bd2a9a39fc9b 100644 (file)
@@ -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