]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: hlua: avoid confusion between internal timers and tick based timers
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 4 Apr 2023 16:41:04 +0000 (18:41 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 19 Apr 2023 09:03:31 +0000 (11:03 +0200)
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.

include/haproxy/hlua-t.h
src/hlua.c

index 22de65932dde63ffcc9b2818befbc39c516c38d2..2672ffdcf4f5aa32843e68ccadbd6e4613fe62fd 100644 (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 */
index bea0cf754a98d89cf74df7de19091df4c816689b..356c04c1b4d34c35613d3a194e5c4b38c1466c90 100644 (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);