From 7b5ca8f4571707be05d9791064b5b04f01f853dd Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Wed, 30 Mar 2022 14:37:49 +0200 Subject: [PATCH] MINOR: channel: Use conn-streams as channel producer and consumer chn_prod() and chn_cons() now return a conn-stream instead of a stream-interface. --- include/haproxy/channel.h | 18 +++++++++--------- src/http_act.c | 2 +- src/http_ana.c | 2 +- src/tcp_rules.c | 16 ++++++++-------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/haproxy/channel.h b/include/haproxy/channel.h index 873ce2ac25..fd78002ad0 100644 --- a/include/haproxy/channel.h +++ b/include/haproxy/channel.h @@ -64,22 +64,22 @@ static inline struct stream *chn_strm(const struct channel *chn) return LIST_ELEM(chn, struct stream *, req); } -/* returns a pointer to the stream interface feeding the channel (producer) */ -static inline struct stream_interface *chn_prod(const struct channel *chn) +/* returns a pointer to the conn-stream feeding the channel (producer) */ +static inline struct conn_stream *chn_prod(const struct channel *chn) { if (chn->flags & CF_ISRESP) - return LIST_ELEM(chn, struct stream *, res)->csb->si; + return LIST_ELEM(chn, struct stream *, res)->csb; else - return LIST_ELEM(chn, struct stream *, req)->csf->si; + return LIST_ELEM(chn, struct stream *, req)->csf; } -/* returns a pointer to the stream interface consuming the channel (producer) */ -static inline struct stream_interface *chn_cons(const struct channel *chn) +/* returns a pointer to the conn-stream consuming the channel (producer) */ +static inline struct conn_stream *chn_cons(const struct channel *chn) { if (chn->flags & CF_ISRESP) - return LIST_ELEM(chn, struct stream *, res)->csf->si; + return LIST_ELEM(chn, struct stream *, res)->csf; else - return LIST_ELEM(chn, struct stream *, req)->csb->si; + return LIST_ELEM(chn, struct stream *, req)->csb; } /* c_orig() : returns the pointer to the channel buffer's origin */ @@ -433,7 +433,7 @@ static inline int channel_is_rewritable(const struct channel *chn) */ static inline int channel_may_send(const struct channel *chn) { - return chn_cons(chn)->state == SI_ST_EST; + return chn_cons(chn)->si->state == SI_ST_EST; } /* HTX version of channel_may_recv(). Returns non-zero if the channel can still diff --git a/src/http_act.c b/src/http_act.c index f35fadfb56..8c53beecfd 100644 --- a/src/http_act.c +++ b/src/http_act.c @@ -718,7 +718,7 @@ static enum act_parse_ret parse_http_set_status(const char **args, int *orig_arg static enum act_return http_action_reject(struct act_rule *rule, struct proxy *px, struct session *sess, struct stream *s, int flags) { - si_must_kill_conn(chn_prod(&s->req)); + si_must_kill_conn(chn_prod(&s->req)->si); channel_abort(&s->req); channel_abort(&s->res); s->req.analysers &= AN_REQ_FLT_END; diff --git a/src/http_ana.c b/src/http_ana.c index 31ba3cc653..a1b6b1fdb4 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -4140,7 +4140,7 @@ enum rule_result http_wait_for_msg_body(struct stream *s, struct channel *chn, if ((htx->flags & HTX_FL_EOM) || htx_get_tail_type(htx) > HTX_BLK_DATA || channel_htx_full(chn, htx, global.tune.maxrewrite) || - si_rx_blocked_room(chn_prod(chn))) + si_rx_blocked_room(chn_prod(chn)->si)) goto end; if (bytes) { diff --git a/src/tcp_rules.c b/src/tcp_rules.c index e4c7647ea2..37d5bed3c1 100644 --- a/src/tcp_rules.c +++ b/src/tcp_rules.c @@ -116,7 +116,7 @@ int tcp_inspect_request(struct stream *s, struct channel *req, int an_bit) */ if ((req->flags & (CF_EOI|CF_SHUTR|CF_READ_ERROR)) || channel_full(req, global.tune.maxrewrite) || - si_rx_blocked_room(chn_prod(req)) || + si_rx_blocked_room(chn_prod(req)->si) || !s->be->tcp_req.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) partial = SMP_OPT_FINAL; else @@ -253,7 +253,7 @@ resume_execution: _HA_ATOMIC_INC(&sess->listener->counters->failed_req); reject: - si_must_kill_conn(chn_prod(req)); + si_must_kill_conn(chn_prod(req)->si); channel_abort(req); channel_abort(&s->res); @@ -299,7 +299,7 @@ int tcp_inspect_response(struct stream *s, struct channel *rep, int an_bit) * - if one rule returns KO, then return KO */ if ((rep->flags & (CF_EOI|CF_SHUTR|CF_READ_ERROR)) || channel_full(rep, global.tune.maxrewrite) || - si_rx_blocked_room(chn_prod(rep)) || + si_rx_blocked_room(chn_prod(rep)->si) || !s->be->tcp_rep.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) partial = SMP_OPT_FINAL; else @@ -390,10 +390,10 @@ resume_execution: goto deny; } else if (rule->action == ACT_TCP_CLOSE) { - chn_prod(rep)->flags |= SI_FL_NOLINGER | SI_FL_NOHALF; - si_must_kill_conn(chn_prod(rep)); - si_shutr(chn_prod(rep)); - si_shutw(chn_prod(rep)); + chn_prod(rep)->si->flags |= SI_FL_NOLINGER | SI_FL_NOHALF; + si_must_kill_conn(chn_prod(rep)->si); + si_shutr(chn_prod(rep)->si); + si_shutw(chn_prod(rep)->si); s->last_rule_file = rule->conf.file; s->last_rule_line = rule->conf.line; goto end; @@ -450,7 +450,7 @@ resume_execution: _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_resp); reject: - si_must_kill_conn(chn_prod(rep)); + si_must_kill_conn(chn_prod(rep)->si); channel_abort(rep); channel_abort(&s->req); -- 2.47.3