]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: lua: Lua tasks fail to start.
authorCamilo Lopez <camilo@camilolopez.com>
Sun, 2 Aug 2015 23:07:28 +0000 (19:07 -0400)
committerWilly Tarreau <w@1wt.eu>
Sun, 9 Aug 2015 08:22:34 +0000 (10:22 +0200)
I've been trying out 1.6 dev3 with lua support, and trying to start
lua tasks seems to not be working.

Using this configuration

global
  lua-load /lua/lol.lua
  debug
  maxconn 4096

backend shard_b
  server db01 mysql_shard_b:3306

backend shard_a
  server db01 mysql_shard_a:3306

listen mysql-cluster
  bind 0.0.0.0:8001
  mode tcp
  balance roundrobin
  use_backend shard_b

And this lua function

  core.register_task(function()
    while true do
      core.Alert("LOLOLOLOLOL")
    end
  end)

I'd always get a timeout error starting the registered function.

The problem lies as far as I can tell in the fact that is possible for
now_ms to not change (is this maybe a problem on my config/system?)
until the expiration check happens, in the resume function that
actually kickstarts the lua task, making HAProxy think that expiration
time for the task is up, if I understand correctly tasks are meant to
never really timeout.

src/hlua.c

index 678935165181d9641a821e7aa1a880d5972e8d1b..8e92134535d17f3e31095928186740af362619fc 100644 (file)
@@ -3780,7 +3780,7 @@ static struct task *hlua_process_task(struct task *task)
         * execution timeouts.
         */
        if (!HLUA_IS_RUNNING(hlua))
-               hlua->expire = tick_add(now_ms, hlua_timeout_task);
+               hlua->expire = tick_add_ifset(now_ms, hlua_timeout_task);
 
        /* Execute the Lua code. */
        status = hlua_ctx_resume(hlua, 1);