]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream: Introduce stream_abort() to abort on both sides in same time
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 13 Apr 2023 13:22:29 +0000 (15:22 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Apr 2023 12:04:59 +0000 (14:04 +0200)
The function stream_abort() should now be called when an abort is performed
on the both channels in same time.

include/haproxy/stream.h
src/http_act.c
src/http_ana.c
src/stream.c
src/tcp_act.c
src/tcp_rules.c

index c4009559257757b5c81407f34f67f569d41e2f3f..19ef92c35032f09181bb87ff3c4cb05ccf10b907 100644 (file)
@@ -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);
index 425b3ab119d56d87c940480b2dea1012b083d204..c80bc51fcec7c13f1ea3109874e9708f58d1c630 100644 (file)
@@ -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;
 
index 4dc1b523f74e8308f448ffef4bb3709c9012df7d..39da847c6d1b1f3f5db8c1b849300620cae23653 100644 (file)
@@ -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);
index 5afef6c8f99528db0b5a8f0d6998b4a443841825..e45b321b5cf53502adb8f279d22077723d1ae4d5 100644 (file)
@@ -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;
                }
        }
index 142e1ba09e684fdb011366f05eebb754703fee86..05ed05695b759b16cfa48a0f8ab0af108c563e1d 100644 (file)
@@ -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)
index 10a45ddf9f9ccde44b3dddfecb39e41da475ceb5..8687df8fb07479d94b11bc9674a2c12c8fb75f4b 100644 (file)
@@ -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;