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.
This commit is contained in:
Christopher Faulet 2022-04-01 17:19:36 +02:00
parent 158f33615d
commit 8f45eec016
5 changed files with 21 additions and 21 deletions

View 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

View 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 */
/*

View 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));

View 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;
}

View 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