From: Willy Tarreau Date: Sun, 27 Sep 2015 08:06:24 +0000 (+0200) Subject: MEDIUM: actions: add new flag ACT_FLAG_FINAL to notify about last call X-Git-Tag: v1.6-dev6~46 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c1b10d38d7a73909cfab61051f71c28e4aaf7431;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/include/types/action.h b/include/types/action.h index 5a581c7ba5..b1e19e7faf 100644 --- a/include/types/action.h +++ b/include/types/action.h @@ -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 { diff --git a/src/proto_tcp.c b/src/proto_tcp.c index baac91a6c2..825f32085d 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -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.