From: Christopher Faulet Date: Wed, 4 Jan 2023 10:55:15 +0000 (+0100) Subject: MINOR: channel: Stop to test CF_READ_ERROR flag if CF_SHUTR is enough X-Git-Tag: v2.8-dev2~71 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4b490b75175585e787e7d83fabc79cd7825d9c1e;p=thirdparty%2Fhaproxy.git MINOR: channel: Stop to test CF_READ_ERROR flag if CF_SHUTR is enough 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. --- diff --git a/include/haproxy/channel.h b/include/haproxy/channel.h index fa504b1eaf..052ffee15a 100644 --- a/include/haproxy/channel.h +++ b/include/haproxy/channel.h @@ -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; diff --git a/src/http_ana.c b/src/http_ana.c index 96eb8cec64..44c2953462 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -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; diff --git a/src/http_fetch.c b/src/http_fetch.c index b5e4f36171..4564f9c4f5 100644 --- a/src/http_fetch.c +++ b/src/http_fetch.c @@ -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; diff --git a/src/stream.c b/src/stream.c index a35f96d38f..8367c89121 100644 --- a/src/stream.c +++ b/src/stream.c @@ -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) && diff --git a/src/tcp_rules.c b/src/tcp_rules.c index 6465e6ed17..15090e3d2d 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 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;