]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tree-wide: Replace several chn_prod() by the corresponding SC
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 13 Apr 2023 14:44:18 +0000 (16:44 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Apr 2023 13:06:04 +0000 (15:06 +0200)
At many places, call to chn_prod() can be easily replaced by the
corresponding SC. It is a bit easier to understand which side is
manipulated.

src/cli.c
src/http_act.c
src/http_ana.c
src/stats.c
src/tcp_rules.c

index 5ac493580f61cbe62b1d354cc9159e2645273154..1dc160da8d9066fc8aeb4fcefd0f181ff423e4b7 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -2692,7 +2692,7 @@ send_status:
        goto read_again;
 
 missing_data:
-        if (chn_prod(req)->flags & SC_FL_ABRT_DONE) {
+        if (s->scf->flags & SC_FL_ABRT_DONE) {
                 /* There is no more request or a only a partial one and we
                  * receive a close from the client, we can leave */
                sc_schedule_shutdown(s->scf);
@@ -2741,7 +2741,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
                return 0;
        }
 
-       if (chn_prod(rep)->flags & SC_FL_ABRT_DONE) {
+       if (s->scb->flags & SC_FL_ABRT_DONE) {
                /* stream cleanup */
 
                pcli_write_prompt(s);
index c80bc51fcec7c13f1ea3109874e9708f58d1c630..596e68c5461b7ebd7a5f9e99fa963702bd0686fc 100644 (file)
@@ -719,7 +719,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)
 {
-       sc_must_kill_conn(chn_prod(&s->req));
+       sc_must_kill_conn(s->scf);
        stream_abort(s);
        s->req.analysers &= AN_REQ_FLT_END;
        s->res.analysers &= AN_RES_FLT_END;
index 3c46f2af950e6d7c1d602e37d02846cd1fce6e06..4ec3a389b9d6b94c6d04196d73ba906fbbcf7bb5 100644 (file)
@@ -114,7 +114,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
                /* An abort at this stage means we are performing a "destructive"
                 * HTTP upgrade (TCP>H2). In this case, we can leave.
                 */
-               if (chn_prod(req)->flags & SC_FL_ABRT_DONE) {
+               if (s->scf->flags & SC_FL_ABRT_DONE) {
                        s->logs.logwait = 0;
                         s->logs.level = 0;
                        stream_abort(s);
@@ -766,7 +766,7 @@ int http_process_tarpit(struct stream *s, struct channel *req, int an_bit)
         * there and that the timeout has not expired.
         */
        channel_dont_connect(req);
-       if (!(chn_prod(req)->flags & SC_FL_ABRT_DONE) &&
+       if (!(s->scf->flags & SC_FL_ABRT_DONE) &&
            !tick_is_expired(req->analyse_exp, now_ms)) {
                /* Be sure to drain all data from the request channel */
                channel_htx_erase(req, htxbuf(&req->buf));
@@ -1002,7 +1002,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
         * it can be abused to exhaust source ports. */
        if (s->be->options & PR_O_ABRT_CLOSE) {
                channel_auto_read(req);
-               if ((chn_prod(req)->flags & SC_FL_ABRT_DONE) && !(txn->flags & TX_CON_WANT_TUN))
+               if ((s->scf->flags & SC_FL_ABRT_DONE) && !(txn->flags & TX_CON_WANT_TUN))
                        s->scb->flags |= SC_FL_NOLINGER;
                channel_auto_close(req);
        }
@@ -1018,7 +1018,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
 
  missing_data_or_waiting:
        /* stop waiting for data if the input is closed before the end */
-       if (msg->msg_state < HTTP_MSG_ENDING && chn_prod(req)->flags & SC_FL_ABRT_DONE)
+       if (msg->msg_state < HTTP_MSG_ENDING && (s->scf->flags & SC_FL_ABRT_DONE))
                goto return_cli_abort;
 
  waiting:
@@ -1294,9 +1294,8 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
                }
 
                /* 3: client abort with an abortonclose */
-               else if ((chn_prod(rep)->flags & SC_FL_ABRT_DONE) &&
-                        (chn_prod(&s->req)->flags & SC_FL_ABRT_DONE) &&
-                        (s->scb->flags & SC_FL_SHUT_DONE)) {
+               else if ((s->scb->flags & (SC_FL_ABRT_DONE|SC_FL_SHUT_DONE)) == (SC_FL_ABRT_DONE|SC_FL_SHUT_DONE) &&
+                        (s->scf->flags & SC_FL_ABRT_DONE)) {
                        _HA_ATOMIC_INC(&sess->fe->fe_counters.cli_aborts);
                        _HA_ATOMIC_INC(&s->be->be_counters.cli_aborts);
                        if (sess->listener && sess->listener->counters)
@@ -1318,7 +1317,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
                }
 
                /* 4: close from server, capture the response if the server has started to respond */
-               else if (chn_prod(rep)->flags & SC_FL_ABRT_DONE) {
+               else if (s->scb->flags & SC_FL_ABRT_DONE) {
                        if ((txn->flags & TX_L7_RETRY) &&
                            (s->be->retry_type & PR_RE_DISCONNECTED)) {
                                if (co_data(rep) || do_l7_retry(s, s->scb) == 0) {
@@ -2060,7 +2059,7 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit
        if (htx->data != co_data(res))
                goto missing_data_or_waiting;
 
-       if (!(msg->flags & HTTP_MSGF_XFER_LEN) && (chn_prod(res)->flags & SC_FL_ABRT_DONE)) {
+       if (!(msg->flags & HTTP_MSGF_XFER_LEN) && (s->scb->flags & SC_FL_ABRT_DONE)) {
                msg->msg_state = HTTP_MSG_ENDING;
                goto ending;
        }
@@ -2128,8 +2127,8 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit
         * so we don't want to count this as a server abort. Otherwise it's a
         * server abort.
         */
-       if (msg->msg_state < HTTP_MSG_ENDING && (chn_prod(res)->flags & SC_FL_ABRT_DONE)) {
-               if ((chn_prod(&s->req)->flags & SC_FL_ABRT_DONE) &&
+       if (msg->msg_state < HTTP_MSG_ENDING && (s->scb->flags & SC_FL_ABRT_DONE)) {
+               if ((s->scf->flags & SC_FL_ABRT_DONE) &&
                    (s->scb->flags & SC_FL_SHUT_DONE))
                        goto return_cli_abort;
                /* If we have some pending data, we continue the processing */
@@ -2674,7 +2673,7 @@ static enum rule_result http_req_get_intercept_rule(struct proxy *px, struct lis
                /* Always call the action function if defined */
                if (rule->action_ptr) {
                        if (sc_ep_test(s->scf, SE_FL_ERROR) ||
-                           ((chn_prod(&s->req)->flags & SC_FL_ABRT_DONE) &&
+                           ((s->scf->flags & SC_FL_ABRT_DONE) &&
                             (px->options & PR_O_ABRT_CLOSE)))
                                act_opts |= ACT_OPT_FINAL;
 
@@ -2837,7 +2836,7 @@ resume_execution:
                /* Always call the action function if defined */
                if (rule->action_ptr) {
                        if (sc_ep_test(s->scf, SE_FL_ERROR) ||
-                           ((chn_prod(&s->req)->flags & SC_FL_ABRT_DONE) &&
+                           ((s->scf->flags & SC_FL_ABRT_DONE) &&
                             (px->options & PR_O_ABRT_CLOSE)))
                                act_opts |= ACT_OPT_FINAL;
 
index 515c2600358593e0588deab19b1bb1910f9d8efc..529f7e6d498e0b51b23f320b191754c7ad14b95e 100644 (file)
@@ -4493,7 +4493,7 @@ static void http_stats_io_handler(struct appctx *appctx)
        if (appctx->st0 == STAT_HTTP_POST) {
                if (stats_process_http_post(sc))
                        appctx->st0 = STAT_HTTP_LAST;
-               else if (chn_prod(req)->flags & SC_FL_ABRT_DONE)
+               else if (s->scf->flags & SC_FL_ABRT_DONE)
                        appctx->st0 = STAT_HTTP_DONE;
        }
 
index ad86ac803d71c3ee0aeef480014d42ad0ca26c63..d6ba9fbc1dfd1b30b1109ffb694bd098180b1a8b 100644 (file)
@@ -117,7 +117,7 @@ int tcp_inspect_request(struct stream *s, struct channel *req, int an_bit)
         */
 
        if ((s->scf->flags & (SC_FL_EOI|SC_FL_ABRT_DONE)) || channel_full(req, global.tune.maxrewrite) ||
-           sc_waiting_room(chn_prod(req)) ||
+           sc_waiting_room(s->scf) ||
            !s->be->tcp_req.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) {
                partial = SMP_OPT_FINAL;
                /* Action may yield while the inspect_delay is not expired and there is no read error */
@@ -254,7 +254,7 @@ resume_execution:
                _HA_ATOMIC_INC(&sess->listener->counters->failed_req);
 
  reject:
-       sc_must_kill_conn(chn_prod(req));
+       sc_must_kill_conn(s->scf);
        stream_abort(s);
 
  abort:
@@ -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 ((s->scb->flags & (SC_FL_EOI|SC_FL_ABRT_DONE)) || channel_full(rep, global.tune.maxrewrite) ||
-           sc_waiting_room(chn_prod(rep)) ||
+           sc_waiting_room(s->scb) ||
            !s->be->tcp_rep.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) {
                partial = SMP_OPT_FINAL;
                /* Action may yield while the inspect_delay is not expired and there is no read error */
@@ -391,10 +391,10 @@ resume_execution:
                                goto deny;
                        }
                        else if (rule->action == ACT_TCP_CLOSE) {
-                               chn_prod(rep)->flags |= SC_FL_NOLINGER | SC_FL_NOHALF;
-                               sc_must_kill_conn(chn_prod(rep));
-                               sc_abort(chn_prod(rep));
-                               sc_shutdown(chn_prod(rep));
+                               s->scb->flags |= SC_FL_NOLINGER | SC_FL_NOHALF;
+                               sc_must_kill_conn(s->scb);
+                               sc_abort(s->scb);
+                               sc_shutdown(s->scb);
                                s->last_rule_file = rule->conf.file;
                                s->last_rule_line = rule->conf.line;
                                goto end;
@@ -451,7 +451,7 @@ resume_execution:
                _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_resp);
 
  reject:
-       sc_must_kill_conn(chn_prod(rep));
+       sc_must_kill_conn(s->scb);
        stream_abort(s);
 
   abort: