CLEANUP: hlua: avoid confusion between internal timers and tick based timers

Not all hlua "time" variables use the same time logic.

hlua->wake_time relies on ticks since its meant to be used in conjunction
with task scheduling. Thus, it should be stored as a signed int and
manipulated using the tick api.
Adding a few comments about that to prevent mixups with hlua internal
timer api which doesn't rely on the ticks api.
This commit is contained in:
Aurelien DARRAGON 2023-04-04 18:41:04 +02:00 committed by Christopher Faulet
parent 58e36e5b14
commit 2a9764baae
2 changed files with 5 additions and 4 deletions

View File

@ -116,7 +116,7 @@ struct hlua {
-1 if the memory context is not used. */
int nargs; /* The number of arguments in the stack at the start of execution. */
unsigned int flags; /* The current execution flags. */
int wake_time; /* The lua wants to be waked at this time, or before. */
int wake_time; /* The lua wants to be waked at this time, or before. (ticks) */
struct hlua_timer timer; /* lua multipurpose timer */
struct task *task; /* The task associated with the lua stack execution.
We must wake this task to continue the task execution */

View File

@ -1369,6 +1369,7 @@ static inline void hlua_sendlog(struct proxy *px, int level, const char *msg)
/* This function just ensure that the yield will be always
* returned with a timeout and permit to set some flags
* <timeout> is a tick value
*/
__LJMP void hlua_yieldk(lua_State *L, int nresults, int ctx,
lua_KFunction k, int timeout, unsigned int flags)
@ -8627,7 +8628,7 @@ __LJMP static int hlua_sleep_yield(lua_State *L, int status, lua_KContext ctx)
__LJMP static int hlua_sleep(lua_State *L)
{
unsigned int delay;
unsigned int wakeup_ms;
int wakeup_ms; // tick value
MAY_LJMP(check_args(L, 1, "sleep"));
@ -8642,7 +8643,7 @@ __LJMP static int hlua_sleep(lua_State *L)
__LJMP static int hlua_msleep(lua_State *L)
{
unsigned int delay;
unsigned int wakeup_ms;
int wakeup_ms; // tick value
MAY_LJMP(check_args(L, 1, "msleep"));
@ -9814,7 +9815,7 @@ __LJMP static int hlua_set_wake_time(lua_State *L)
{
struct hlua *hlua;
unsigned int delay;
unsigned int wakeup_ms;
int wakeup_ms; // tick value
/* Get hlua struct, or NULL if we execute from main lua state */
hlua = hlua_gethlua(L);