mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 23:56:57 +02:00
MEDIUM: lua: Set the analyse expiration date with smaller wake_time only
If a lua action yields for any reason and if the wake timeout is set, it only override the analyse expiration date if it is smaller. This way, a lower inspect-delay will be respected, if any.
This commit is contained in:
parent
2747fbb7ac
commit
8f587ea347
37
src/hlua.c
37
src/hlua.c
@ -6534,7 +6534,6 @@ __LJMP static int hlua_set_wake_time(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* This function is a wrapper to execute each LUA function declared as an action
|
/* This function is a wrapper to execute each LUA function declared as an action
|
||||||
* wrapper during the initialisation period. This function may return any
|
* wrapper during the initialisation period. This function may return any
|
||||||
* ACT_RET_* value. On error ACT_RET_CONT is returned and the action is
|
* ACT_RET_* value. On error ACT_RET_CONT is returned and the action is
|
||||||
@ -6631,15 +6630,6 @@ static enum act_return hlua_action(struct act_rule *rule, struct proxy *px,
|
|||||||
s->hlua->max_time = hlua_timeout_session;
|
s->hlua->max_time = hlua_timeout_session;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Always reset the analyse expiration timeout for the corresponding
|
|
||||||
* channel in case the lua script yield, to be sure to not keep an
|
|
||||||
* expired timeout.
|
|
||||||
*/
|
|
||||||
if (dir == SMP_OPT_DIR_REQ)
|
|
||||||
s->req.analyse_exp = TICK_ETERNITY;
|
|
||||||
else
|
|
||||||
s->res.analyse_exp = TICK_ETERNITY;
|
|
||||||
|
|
||||||
/* Execute the function. */
|
/* Execute the function. */
|
||||||
switch (hlua_ctx_resume(s->hlua, !(flags & ACT_OPT_FINAL))) {
|
switch (hlua_ctx_resume(s->hlua, !(flags & ACT_OPT_FINAL))) {
|
||||||
/* finished. */
|
/* finished. */
|
||||||
@ -6653,24 +6643,25 @@ static enum act_return hlua_action(struct act_rule *rule, struct proxy *px,
|
|||||||
if (flags & ACT_OPT_FINAL)
|
if (flags & ACT_OPT_FINAL)
|
||||||
goto err_yield;
|
goto err_yield;
|
||||||
|
|
||||||
if (s->hlua->wake_time != TICK_ETERNITY) {
|
if (dir == SMP_OPT_DIR_REQ)
|
||||||
if (dir == SMP_OPT_DIR_REQ)
|
s->req.analyse_exp = tick_first((tick_is_expired(s->req.analyse_exp, now_ms) ? 0 : s->req.analyse_exp),
|
||||||
s->req.analyse_exp = s->hlua->wake_time;
|
s->hlua->wake_time);
|
||||||
else
|
else
|
||||||
s->res.analyse_exp = s->hlua->wake_time;
|
s->res.analyse_exp = tick_first((tick_is_expired(s->res.analyse_exp, now_ms) ? 0 : s->res.analyse_exp),
|
||||||
}
|
s->hlua->wake_time);
|
||||||
}
|
}
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
/* yield. */
|
/* yield. */
|
||||||
case HLUA_E_AGAIN:
|
case HLUA_E_AGAIN:
|
||||||
/* Set timeout in the required channel. */
|
/* Set timeout in the required channel. */
|
||||||
if (s->hlua->wake_time != TICK_ETERNITY) {
|
if (dir == SMP_OPT_DIR_REQ)
|
||||||
if (dir == SMP_OPT_DIR_REQ)
|
s->req.analyse_exp = tick_first((tick_is_expired(s->req.analyse_exp, now_ms) ? 0 : s->req.analyse_exp),
|
||||||
s->req.analyse_exp = s->hlua->wake_time;
|
s->hlua->wake_time);
|
||||||
else
|
else
|
||||||
s->res.analyse_exp = s->hlua->wake_time;
|
s->res.analyse_exp = tick_first((tick_is_expired(s->res.analyse_exp, now_ms) ? 0 : s->res.analyse_exp),
|
||||||
}
|
s->hlua->wake_time);
|
||||||
|
|
||||||
/* Some actions can be wake up when a "write" event
|
/* Some actions can be wake up when a "write" event
|
||||||
* is detected on a response channel. This is useful
|
* is detected on a response channel. This is useful
|
||||||
* only for actions targeted on the requests.
|
* only for actions targeted on the requests.
|
||||||
@ -6715,6 +6706,8 @@ static enum act_return hlua_action(struct act_rule *rule, struct proxy *px,
|
|||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
if (act_ret != ACT_RET_YIELD)
|
||||||
|
s->hlua->wake_time = TICK_ETERNITY;
|
||||||
return act_ret;
|
return act_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user