]> git.ipfire.org Git - thirdparty/collectd.git/commit
lua: Use a global lock to call Lua's API 3777/head
authorTakuro Ashie <ashie@clear-code.com>
Mon, 26 Oct 2020 02:22:29 +0000 (11:22 +0900)
committerKentaro Hayashi <hayashi@clear-code.com>
Sat, 30 Dec 2023 13:24:51 +0000 (22:24 +0900)
commit19f7f04fef3179cd9379a982e54313fae999eb01
treef6675352cae4c0122bf37d888d5a6d1106d4044e
parentbd16b56d02ef55d8aebeb65fd233ae1a99ef0432
lua: Use a global lock to call Lua's API

Since vanilla Lua isn't multi-thread-safe, a global lock should be used
when calling their functions. The previous code causes unstable behavior
especially on loading Lua's C modules with both read & write threads.

e.g.)

  collectd.register_read(function()
    require('cqueues')
    return 0
  end)

  collectd.register_write(function()
    return 0
  end)

Note that you need to add the following config to your collectd.conf to
load C modules:

  <LoadPlugin lua>
    Globals true
  </LoadPlugin>

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
src/lua.c