]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: channel: Stop to test CF_READ_ERROR flag if CF_SHUTR is enough
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 4 Jan 2023 10:55:15 +0000 (11:55 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 9 Jan 2023 17:41:08 +0000 (18:41 +0100)
When a read error (CF_READ_ERROR) is reported, a shutdown for reads is
always performed (CF_SHUTR). Thus, there is no reason to check if
CF_READ_ERROR is set if CF_SHUTR is also checked.

include/haproxy/channel.h
src/http_ana.c
src/http_fetch.c
src/stream.c
src/tcp_rules.c

index fa504b1eaffa97fed5ff27a791589ad7464a896d..052ffee15abb02edea59e927cfd04058326fffec 100644 (file)
@@ -530,7 +530,7 @@ static inline int channel_output_closed(struct channel *chn)
  */
 static inline void channel_check_timeouts(struct channel *chn)
 {
-       if (likely(!(chn->flags & (CF_SHUTR|CF_READ_TIMEOUT|CF_READ_EVENT|CF_READ_ERROR|CF_READ_NOEXP))) &&
+       if (likely(!(chn->flags & (CF_SHUTR|CF_READ_TIMEOUT|CF_READ_EVENT|CF_READ_NOEXP))) &&
            unlikely(tick_is_expired(chn->rex, now_ms)))
                chn->flags |= CF_READ_TIMEOUT;
 
index 96eb8cec64dbea78c4d0efdffb4a507343185668..44c2953462153069b5f413091443b74ee162d451 100644 (file)
@@ -865,7 +865,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 ((req->flags & (CF_SHUTR|CF_READ_ERROR)) == 0 &&
+       if (!(req->flags & CF_SHUTR) &&
            !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));
@@ -4244,7 +4244,7 @@ enum rule_result http_wait_for_msg_body(struct stream *s, struct channel *chn,
        }
 
        /* we get here if we need to wait for more data */
-       if (!(chn->flags & (CF_SHUTR | CF_READ_ERROR))) {
+       if (!(chn->flags & CF_SHUTR)) {
                if (!tick_isset(chn->analyse_exp))
                        chn->analyse_exp = tick_add_ifset(now_ms, time);
                ret = HTTP_RULE_RES_YIELD;
index b5e4f3617189995169d354c5712e512a31eea637..4564f9c4f5b99e8f741639aaffcac94ce3b8dbed 100644 (file)
@@ -615,7 +615,7 @@ static int smp_fetch_body(const struct arg *args, struct sample *smp, const char
        smp->flags = SMP_F_VOL_TEST;
 
        if (!finished && (check || (chn && !channel_full(chn, global.tune.maxrewrite) &&
-                                   !(chn->flags & (CF_EOI|CF_SHUTR|CF_READ_ERROR)))))
+                                   !(chn->flags & (CF_EOI|CF_SHUTR)))))
                smp->flags |= SMP_F_MAY_CHANGE;
 
        return 1;
index a35f96d38f2e5ab52401bc0ad8ef7ac7cb79aedd..8367c891216c07f6e154ac457186e99c94a8ad03 100644 (file)
@@ -1781,7 +1781,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
                 * timeout needs to be refreshed.
                 */
                if (!((req->flags | res->flags) &
-                     (CF_SHUTR|CF_READ_EVENT|CF_READ_ERROR|CF_READ_TIMEOUT|CF_SHUTW|
+                     (CF_SHUTR|CF_READ_EVENT|CF_READ_TIMEOUT|CF_SHUTW|
                       CF_WRITE_EVENT|CF_WRITE_ERROR|CF_WRITE_TIMEOUT)) &&
                    !(s->flags & SF_CONN_EXP) &&
                    !((sc_ep_get(scf) | scb->flags) & SE_FL_ERROR) &&
index 6465e6ed17a874a2539ad17b2b380c818eb526dd..15090e3d2de0e57a09e501542534ccf1201aab82 100644 (file)
@@ -116,7 +116,7 @@ int tcp_inspect_request(struct stream *s, struct channel *req, int an_bit)
         * - if one rule returns KO, then return KO
         */
 
-       if ((req->flags & (CF_EOI|CF_SHUTR|CF_READ_ERROR)) || channel_full(req, global.tune.maxrewrite) ||
+       if ((req->flags & (CF_EOI|CF_SHUTR)) || channel_full(req, global.tune.maxrewrite) ||
            sc_waiting_room(chn_prod(req)) ||
            !s->be->tcp_req.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) {
                partial = SMP_OPT_FINAL;
@@ -299,7 +299,7 @@ int tcp_inspect_response(struct stream *s, struct channel *rep, int an_bit)
         * - if one rule returns OK, then return OK
         * - if one rule returns KO, then return KO
         */
-       if ((rep->flags & (CF_EOI|CF_SHUTR|CF_READ_ERROR)) || channel_full(rep, global.tune.maxrewrite) ||
+       if ((rep->flags & (CF_EOI|CF_SHUTR)) || channel_full(rep, global.tune.maxrewrite) ||
            sc_waiting_room(chn_prod(rep)) ||
            !s->be->tcp_rep.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) {
                partial = SMP_OPT_FINAL;