]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: channel: Use conn-streams as channel producer and consumer
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 30 Mar 2022 12:37:49 +0000 (14:37 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 13 Apr 2022 13:10:14 +0000 (15:10 +0200)
chn_prod() and chn_cons() now return a conn-stream instead of a
stream-interface.

include/haproxy/channel.h
src/http_act.c
src/http_ana.c
src/tcp_rules.c

index 873ce2ac2551488659211f2c4ee0a7cd9bca513b..fd78002ad0edc224cb4e4b6e10d30b7e9367475c 100644 (file)
@@ -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
index f35fadfb56b83ee1694924adfc5694017500a5ac..8c53beecfdaa5bc2abd7ca3517a0e40b99a04c69 100644 (file)
@@ -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;
index 31ba3cc653761a83981ac9ca9ed641dd0b25d093..a1b6b1fdb4af467cd84773a16d19b7f3e2682f7f 100644 (file)
@@ -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) {
index e4c7647ea270b0e7763cc3140eaa1c99e7f28b2a..37d5bed3c1a5b299c698ce3606fcf360b4f94623 100644 (file)
@@ -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);