REORG: stream-int: Uninline si_sync_recv() and make si_cs_recv() private

This way si_*_recv() and si_*_sned() API are defined the same
way. si_sync_snd/si_sync_recv are both exported and defined in the C
file. And si_cs_send/si_cs_recv are private and only used by
stream-interface internals.
This commit is contained in:
Christopher Faulet 2022-02-28 09:21:58 +01:00
parent 494162381e
commit 9936dc6577
2 changed files with 27 additions and 27 deletions

View File

@ -47,9 +47,9 @@ struct appctx *si_register_handler(struct stream_interface *si, struct applet *a
void si_applet_wake_cb(struct stream_interface *si);
void si_update_rx(struct stream_interface *si);
void si_update_tx(struct stream_interface *si);
int si_cs_recv(struct conn_stream *cs);
struct task *si_cs_io_cb(struct task *t, void *ctx, unsigned int state);
void si_update_both(struct stream_interface *si_f, struct stream_interface *si_b);
int si_sync_recv(struct stream_interface *si);
void si_sync_send(struct stream_interface *si);
/* returns the channel which receives data from this stream interface (input channel) */
@ -360,30 +360,6 @@ static inline void si_chk_rcv(struct stream_interface *si)
si->ops->chk_rcv(si);
}
/* This tries to perform a synchronous receive on the stream interface to
* try to collect last arrived data. In practice it's only implemented on
* conn_streams. Returns 0 if nothing was done, non-zero if new data or a
* shutdown were collected. This may result on some delayed receive calls
* to be programmed and performed later, though it doesn't provide any
* such guarantee.
*/
static inline int si_sync_recv(struct stream_interface *si)
{
if (!si_state_in(si->state, SI_SB_RDY|SI_SB_EST))
return 0;
if (!cs_conn_mux(si->cs))
return 0; // only conn_streams are supported
if (si->wait_event.events & SUB_RETRY_RECV)
return 0; // already subscribed
if (!si_rx_endp_ready(si) || si_rx_blocked(si))
return 0; // already failed
return si_cs_recv(si->cs);
}
/* Calls chk_snd on the connection using the data layer */
static inline void si_chk_snd(struct stream_interface *si)
{

View File

@ -92,7 +92,7 @@ struct si_ops si_applet_ops = {
/* Functions used to communicate with a conn_stream. The first two may be used
* directly, the last one is mostly a wake callback.
*/
int si_cs_recv(struct conn_stream *cs);
static int si_cs_recv(struct conn_stream *cs);
static int si_cs_send(struct conn_stream *cs);
static int si_cs_process(struct conn_stream *cs);
@ -938,6 +938,30 @@ void si_update_tx(struct stream_interface *si)
}
}
/* This tries to perform a synchronous receive on the stream interface to
* try to collect last arrived data. In practice it's only implemented on
* conn_streams. Returns 0 if nothing was done, non-zero if new data or a
* shutdown were collected. This may result on some delayed receive calls
* to be programmed and performed later, though it doesn't provide any
* such guarantee.
*/
int si_sync_recv(struct stream_interface *si)
{
if (!si_state_in(si->state, SI_SB_RDY|SI_SB_EST))
return 0;
if (!cs_conn_mux(si->cs))
return 0; // only conn_streams are supported
if (si->wait_event.events & SUB_RETRY_RECV)
return 0; // already subscribed
if (!si_rx_endp_ready(si) || si_rx_blocked(si))
return 0; // already failed
return si_cs_recv(si->cs);
}
/* perform a synchronous send() for the stream interface. The CF_WRITE_NULL and
* CF_WRITE_PARTIAL flags are cleared prior to the attempt, and will possibly
* be updated in case of success.
@ -1245,7 +1269,7 @@ static void stream_int_chk_snd_conn(struct stream_interface *si)
* into the buffer from the connection. It iterates over the mux layer's
* rcv_buf function.
*/
int si_cs_recv(struct conn_stream *cs)
static int si_cs_recv(struct conn_stream *cs)
{
struct connection *conn = __cs_conn(cs);
struct stream_interface *si = cs_si(cs);