]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http_ana: position the FINAL flag for http_after_res execution
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 4 Sep 2023 14:46:50 +0000 (16:46 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 6 Sep 2023 09:42:34 +0000 (11:42 +0200)
Ensure that the ACT_OPT_FINAL flag is always set when executing actions
from http_after_res context.

This will permit lua functions to be executed as http_after_res actions
since hlua_ctx_resume() automatically disables "yielding" when such flag
is set: the hlua handler will only allow 1shot executions at this point
(lua or not, we don't wan't to reschedule http_after_res actions).

src/http_ana.c

index 6b2d7f0f3e715921a4c98881495b1b7d90a3b32e..819472c17cfde0227784c8c1d18f6e4c75d5f669 100644 (file)
@@ -60,7 +60,7 @@ static void http_debug_stline(const char *dir, struct stream *s, const struct ht
 static void http_debug_hdr(const char *dir, struct stream *s, const struct ist n, const struct ist v);
 
 static enum rule_result http_req_get_intercept_rule(struct proxy *px, struct list *def_rules, struct list *rules, struct stream *s);
-static enum rule_result http_res_get_intercept_rule(struct proxy *px, struct list *def_rules, struct list *rules, struct stream *s);
+static enum rule_result http_res_get_intercept_rule(struct proxy *px, struct list *def_rules, struct list *rules, struct stream *s, uint8_t final);
 static enum rule_result http_req_restrict_header_names(struct stream *s, struct htx *htx, struct proxy *px);
 
 static void http_manage_client_side_cookies(struct stream *s, struct channel *req);
@@ -1709,7 +1709,7 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
                        def_rules = ((cur_proxy->defpx && (cur_proxy == s->be || cur_proxy->defpx != s->be->defpx)) ? &cur_proxy->defpx->http_res_rules : NULL);
                        rules = &cur_proxy->http_res_rules;
 
-                       ret = http_res_get_intercept_rule(cur_proxy, def_rules, rules, s);
+                       ret = http_res_get_intercept_rule(cur_proxy, def_rules, rules, s, 0);
 
                        switch (ret) {
                        case HTTP_RULE_RES_YIELD: /* some data miss, call the function later. */
@@ -2787,7 +2787,7 @@ static enum rule_result http_req_get_intercept_rule(struct proxy *px, struct lis
  * function with the same context.
  */
 static enum rule_result http_res_get_intercept_rule(struct proxy *px, struct list *def_rules,
-                                                   struct list *rules, struct stream *s)
+                                                   struct list *rules, struct stream *s, uint8_t final)
 {
        struct session *sess = strm_sess(s);
        struct http_txn *txn = s->txn;
@@ -2795,6 +2795,8 @@ static enum rule_result http_res_get_intercept_rule(struct proxy *px, struct lis
        enum rule_result rule_ret = HTTP_RULE_RES_CONT;
        int act_opts = 0;
 
+       if (final)
+               act_opts |= ACT_OPT_FINAL;
        /* If "the current_rule_list" match the executed rule list, we are in
         * resume condition. If a resume is needed it is always in the action
         * and never in the ACL or converters. In this case, we initialise the
@@ -2955,11 +2957,11 @@ int http_eval_after_res_rules(struct stream *s)
        def_rules = (s->be->defpx ? &s->be->defpx->http_after_res_rules : NULL);
        rules = &s->be->http_after_res_rules;
 
-       ret = http_res_get_intercept_rule(s->be, def_rules, rules, s);
+       ret = http_res_get_intercept_rule(s->be, def_rules, rules, s, 1);
        if ((ret == HTTP_RULE_RES_CONT || ret == HTTP_RULE_RES_STOP) && sess->fe != s->be) {
                def_rules = ((sess->fe->defpx && sess->fe->defpx != s->be->defpx) ? &sess->fe->defpx->http_after_res_rules : NULL);
                rules = &sess->fe->http_after_res_rules;
-               ret = http_res_get_intercept_rule(sess->fe, def_rules, rules, s);
+               ret = http_res_get_intercept_rule(sess->fe, def_rules, rules, s, 1);
        }
 
   end: