lua-zlib
lua-zlib copied to clipboard
_G write guard whines about zlib being global and could cause race conditions
when I do this
local zlib = require ("zlib")
nginx error log would show: [warn] 30914#30914: *24397 [lua] _G write guard:12: writing a global lua variable ('zlib') which may lead to race conditions between concurrent requests, so prefer the use of 'local' variables stack traceback: [C]: at 0x7f165255b755 [C]: in function 'require'
any light ?
Maybe because we use the old luaL_register function when we should be using luaL_setfuncs?
https://github.com/brimworks/lua-zlib/blob/master/lua_zlib.c#L1263
Feel free to issue a pull request if this change fixes your issue.
Thanks! -Brian
I had the same issue and could fix it by replacing the luaL_register with this:
lua_newtable(L);
luaL_setfuncs(L, zlib_functions, 0);
It works when importing from openresty (luajit), but not from standalone Lua 5.1
Perhaps a little "macro magic" could solve this problem? Pull requests are welcomed :).
I had the same issue with lua-zlib-1.2
If you use OpenResty, maybe can refer to this openresty/openresty#510 as a workaround.