MEDIUM: actions: add new flag ACT_FLAG_FINAL to notify about last call

This new flag indicates to a custom action that it must not yield because
it will not be called anymore. This addresses an issue introduced by commit
bc4c1ac ("MEDIUM: http/tcp: permit to resume http and tcp custom actions"),
which made it possible to yield even after the last call and causes Lua
actions not to be stopped when the session closes. Note that the Lua issue
is not fixed yet at this point. Also only TCP rules were handled, for now
HTTP rules continue to let the action yield since we don't know whether or
not it is a final call.
This commit is contained in:
Willy Tarreau 2015-09-27 10:06:24 +02:00
parent 658b85b68d
commit c1b10d38d7
2 changed files with 5 additions and 3 deletions

View File

@ -49,6 +49,7 @@ enum act_parse_ret {
/* flags passed to custom actions */
enum act_flag {
ACT_FLAG_NONE = 0x00000000, /* no flag */
ACT_FLAG_FINAL = 0x00000001, /* last call, cannot yield */
};
enum act_name {

View File

@ -1165,7 +1165,8 @@ resume_execution:
/* Custom keywords. */
if (!rule->action_ptr)
continue;
switch (rule->action_ptr(rule, s->be, s->sess, s, 0)) {
switch (rule->action_ptr(rule, s->be, s->sess, s, (partial & SMP_OPT_FINAL) ? ACT_FLAG_FINAL : 0)) {
case ACT_RET_ERR:
case ACT_RET_CONT:
continue;
@ -1294,7 +1295,7 @@ resume_execution:
/* Custom keywords. */
if (!rule->action_ptr)
continue;
switch (rule->action_ptr(rule, s->be, s->sess, s, 0)) {
switch (rule->action_ptr(rule, s->be, s->sess, s, (partial & SMP_OPT_FINAL) ? ACT_FLAG_FINAL : 0)) {
case ACT_RET_ERR:
case ACT_RET_CONT:
continue;
@ -1382,7 +1383,7 @@ int tcp_exec_req_rules(struct session *sess)
/* Custom keywords. */
if (rule->action_ptr)
break;
switch (rule->action_ptr(rule, sess->fe, sess, NULL, 0)) {
switch (rule->action_ptr(rule, sess->fe, sess, NULL, ACT_FLAG_FINAL)) {
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.