Inside req.lua, rec_cdata is declared at file scope. The comment above it says:
we can share the cdata here since we only need it temporarily for serialization inside the shared dict
As you know, file scope variables can be shared between nginx processes if you 'require' the lua files using 'init_by_lua_block'. Along with that, I logged the rec_cdata pointer like so:
@esoterix nginx worker processes are single-threaded. So it is safe when there is no yielding (Lua coroutine yielding) in the middle of each individual use cycle of that shared Lua cdata.
Inside req.lua,
rec_cdata
is declared at file scope. The comment above it says:we can share the cdata here since we only need it temporarily for serialization inside the shared dict
As you know, file scope variables can be shared between nginx processes if you 'require' the lua files using 'init_by_lua_block'. Along with that, I logged the rec_cdata pointer like so:
and it showed that the same pointer was being used by all worker processes.