From: Christopher Faulet Date: Thu, 13 Apr 2023 13:22:29 +0000 (+0200) Subject: MINOR: stream: Introduce stream_abort() to abort on both sides in same time X-Git-Tag: v2.8-dev8~156 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7eb837df4adec2e4487898c89cae12c7605e7b1c;p=thirdparty%2Fhaproxy.git MINOR: stream: Introduce stream_abort() to abort on both sides in same time The function stream_abort() should now be called when an abort is performed on the both channels in same time. --- diff --git a/include/haproxy/stream.h b/include/haproxy/stream.h index c400955925..19ef92c350 100644 --- a/include/haproxy/stream.h +++ b/include/haproxy/stream.h @@ -388,6 +388,7 @@ static inline int stream_check_conn_timeout(struct stream *s) int stream_set_timeout(struct stream *s, enum act_timeout_name name, int timeout); void stream_retnclose(struct stream *s, const struct buffer *msg); void sess_set_term_flags(struct stream *s); +void stream_abort(struct stream *s); void service_keywords_register(struct action_kw_list *kw_list); struct action_kw *service_find(const char *kw); diff --git a/src/http_act.c b/src/http_act.c index 425b3ab119..c80bc51fce 100644 --- a/src/http_act.c +++ b/src/http_act.c @@ -720,8 +720,7 @@ static enum act_return http_action_reject(struct act_rule *rule, struct proxy *p struct session *sess, struct stream *s, int flags) { sc_must_kill_conn(chn_prod(&s->req)); - channel_abort(&s->req); - channel_abort(&s->res); + stream_abort(s); s->req.analysers &= AN_REQ_FLT_END; s->res.analysers &= AN_RES_FLT_END; diff --git a/src/http_ana.c b/src/http_ana.c index 4dc1b523f7..39da847c6d 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -117,8 +117,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit) if (chn_prod(req)->flags & SC_FL_SHUTR) { s->logs.logwait = 0; s->logs.level = 0; - channel_abort(&s->req); - channel_abort(&s->res); + stream_abort(s); req->analysers &= AN_REQ_FLT_END; req->analyse_exp = TICK_ETERNITY; DBG_TRACE_LEAVE(STRM_EV_STRM_ANA, s); diff --git a/src/stream.c b/src/stream.c index 5afef6c8f9..e45b321b5c 100644 --- a/src/stream.c +++ b/src/stream.c @@ -830,6 +830,13 @@ void stream_process_counters(struct stream *s) } } +/* Abort processing on the both channels in same time */ +void stream_abort(struct stream *s) +{ + channel_abort(&s->req); + channel_abort(&s->res); +} + /* * Returns a message to the client ; the connection is shut down for read, * and the request is cleared so that no server connection can be initiated. @@ -1143,8 +1150,7 @@ static int process_switching_rules(struct stream *s, struct channel *req, int an sw_failed: /* immediately abort this request in case of allocation failure */ - channel_abort(&s->req); - channel_abort(&s->res); + stream_abort(s); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_RESOURCE; @@ -1515,8 +1521,7 @@ int stream_set_http_mode(struct stream *s, const struct mux_proto_list *mux_prot */ s->logs.logwait = 0; s->logs.level = 0; - channel_abort(&s->req); - channel_abort(&s->res); + stream_abort(s); s->req.analysers &= AN_REQ_FLT_END; s->req.analyse_exp = TICK_ETERNITY; } @@ -3030,8 +3035,7 @@ static enum act_return tcp_action_switch_stream_mode(struct act_rule *rule, stru if (!IS_HTX_STRM(s) && mode == PR_MODE_HTTP) { if (!stream_set_http_mode(s, mux_proto)) { - channel_abort(&s->req); - channel_abort(&s->res); + stream_abort(s); return ACT_RET_ABRT; } } diff --git a/src/tcp_act.c b/src/tcp_act.c index 142e1ba09e..05ed05695b 100644 --- a/src/tcp_act.c +++ b/src/tcp_act.c @@ -337,8 +337,7 @@ static enum act_return tcp_exec_action_silent_drop(struct act_rule *rule, struct out: /* kill the stream if any */ if (strm) { - channel_abort(&strm->req); - channel_abort(&strm->res); + stream_abort(strm); strm->req.analysers &= AN_REQ_FLT_END; strm->res.analysers &= AN_RES_FLT_END; if (strm->flags & SF_BE_ASSIGNED) diff --git a/src/tcp_rules.c b/src/tcp_rules.c index 10a45ddf9f..8687df8fb0 100644 --- a/src/tcp_rules.c +++ b/src/tcp_rules.c @@ -255,8 +255,7 @@ resume_execution: reject: sc_must_kill_conn(chn_prod(req)); - channel_abort(req); - channel_abort(&s->res); + stream_abort(s); abort: req->analysers &= AN_REQ_FLT_END; @@ -453,8 +452,7 @@ resume_execution: reject: sc_must_kill_conn(chn_prod(rep)); - channel_abort(rep); - channel_abort(&s->req); + stream_abort(s); abort: rep->analysers &= AN_RES_FLT_END;