]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: http: pass ACT_FLAG_FINAL to custom actions
authorWilly Tarreau <w@1wt.eu>
Sun, 27 Sep 2015 08:33:15 +0000 (10:33 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 27 Sep 2015 09:04:06 +0000 (11:04 +0200)
In HTTP it's more difficult to know when to pass the flag or not
because all actions are supposed to be final and there's no inspection
delay. Also, the input channel may very well be closed without this
being an error. So we only set the flag when option abortonclose is
set and the input channel is closed, which is the only case where the
user explicitly wants to forward a close down the chain.

src/proto_http.c

index d04c15f1d300110a096662956f93172e02ea6595..e646f790019019f0e9e17750885055af2479129d 100644 (file)
@@ -3497,6 +3497,7 @@ http_req_get_intercept_rule(struct proxy *px, struct list *rules, struct stream
        struct act_rule *rule;
        struct hdr_ctx ctx;
        const char *auth_realm;
+       int 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
@@ -3709,7 +3710,11 @@ resume_execution:
                        }
 
                case ACT_CUSTOM:
-                       switch (rule->action_ptr(rule, px, s->sess, s, 0)) {
+                       final = 0;
+                       if (px->options & PR_O_ABRT_CLOSE)
+                               final = (s->req.flags & (CF_SHUTR|CF_READ_NULL|CF_READ_ERROR));
+
+                       switch (rule->action_ptr(rule, px, s->sess, s, final)) {
                        case ACT_RET_ERR:
                        case ACT_RET_CONT:
                                break;
@@ -3804,6 +3809,7 @@ http_res_get_intercept_rule(struct proxy *px, struct list *rules, struct stream
        struct connection *cli_conn;
        struct act_rule *rule;
        struct hdr_ctx ctx;
+       int 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
@@ -3991,7 +3997,11 @@ resume_execution:
                        return HTTP_RULE_RES_DONE;
 
                case ACT_CUSTOM:
-                       switch (rule->action_ptr(rule, px, s->sess, s, 0)) {
+                       final = 0;
+                       if (px->options & PR_O_ABRT_CLOSE)
+                               final = (s->req.flags & (CF_SHUTR|CF_READ_NULL|CF_READ_ERROR));
+
+                       switch (rule->action_ptr(rule, px, s->sess, s, final)) {
                        case ACT_RET_ERR:
                        case ACT_RET_CONT:
                                break;