MEDIUM: actions: remove ACTION_STOP
Before this patch, two type of custom actions exists: ACT_ACTION_CONT and
ACT_ACTION_STOP. ACT_ACTION_CONT is a non terminal action and ACT_ACTION_STOP is
a terminal action.
Note that ACT_ACTION_STOP is not used in HAProxy.
This patch remove this behavior. Only type type of custom action exists, and it
is called ACT_CUSTOM. Now, the custion action can return a code indicating the
required behavior. ACT_RET_CONT wants that HAProxy continue the current rule
list evaluation, and ACT_RET_STOP wants that HAPRoxy stops the the current rule
list evaluation.
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index c89360c..e671e41 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -1163,21 +1163,19 @@
}
else {
/* Custom keywords. */
- if (rule->action_ptr) {
- switch (rule->action_ptr(rule, s->be, s->sess, s)) {
- case ACT_RET_ERR:
- case ACT_RET_CONT:
- break;
- case ACT_RET_YIELD:
- s->current_rule = rule;
- goto missing_data;
- }
- }
-
- /* accept */
- if (rule->action == ACT_ACTION_STOP)
+ if (!rule->action_ptr)
+ continue;
+ switch (rule->action_ptr(rule, s->be, s->sess, s)) {
+ case ACT_RET_ERR:
+ case ACT_RET_CONT:
+ continue;
+ case ACT_RET_STOP:
break;
- /* otherwise continue */
+ case ACT_RET_YIELD:
+ s->current_rule = rule;
+ goto missing_data;
+ }
+ break; /* ACT_RET_STOP */
}
}
}
@@ -1294,22 +1292,20 @@
}
else {
/* Custom keywords. */
- if (rule->action_ptr) {
- switch (rule->action_ptr(rule, s->be, s->sess, s)) {
- case ACT_RET_ERR:
- case ACT_RET_CONT:
- break;
- case ACT_RET_YIELD:
- channel_dont_close(rep);
- s->current_rule = rule;
- return 0;
- }
- }
-
- /* accept */
- if (rule->action == ACT_ACTION_STOP)
+ if (!rule->action_ptr)
+ continue;
+ switch (rule->action_ptr(rule, s->be, s->sess, s)) {
+ case ACT_RET_ERR:
+ case ACT_RET_CONT:
+ continue;
+ case ACT_RET_STOP:
break;
- /* otherwise continue */
+ case ACT_RET_YIELD:
+ channel_dont_close(rep);
+ s->current_rule = rule;
+ return 0;
+ }
+ break; /* ACT_RET_STOP */
}
}
}
@@ -1384,26 +1380,24 @@
}
else {
/* Custom keywords. */
- if (rule->action_ptr) {
- switch (rule->action_ptr(rule, sess->fe, sess, NULL)) {
- case ACT_RET_YIELD:
- /* yield is not allowed at this point. If this return code is
- * used it is a bug, so I prefer to abort the process.
- */
- send_log(sess->fe, LOG_WARNING,
- "Internal error: yield not allowed with tcp-request connection actions.");
- case ACT_RET_CONT:
- break;
- case ACT_RET_ERR:
- result = 0;
- break;
- }
- if (rule->action == ACT_ACTION_CONT)
- continue;
+ if (rule->action_ptr)
+ break;
+ switch (rule->action_ptr(rule, sess->fe, sess, NULL)) {
+ case ACT_RET_YIELD:
+ /* yield is not allowed at this point. If this return code is
+ * used it is a bug, so I prefer to abort the process.
+ */
+ send_log(sess->fe, LOG_WARNING,
+ "Internal error: yield not allowed with tcp-request connection actions.");
+ case ACT_RET_STOP:
+ break;
+ case ACT_RET_CONT:
+ continue;
+ case ACT_RET_ERR:
+ result = 0;
+ break;
}
-
- /* otherwise it's an accept */
- break;
+ break; /* ACT_RET_STOP */
}
}
}