Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is global environment of each lua handler not isolated when OpenResty's LuaJIT is used? #2277

Open
Rcyyy opened this issue Jan 7, 2024 · 0 comments

Comments

@Rcyyy
Copy link

Rcyyy commented Jan 7, 2024

OpenResty version used in my issue: 1.21.4.3

It's said in the section Lua Variable Scope that each request handler has its own set of Lua global variables.But It's not so in the source code here:

openresty_luajit

Only the version built without OpenResty's LuaJIT(eg. without the micro OPENRESTY_LUAJIT) can have a new table as global environment in each lua coroutine.

I also did experiment on two versions of OpenResty, one was built with OpenResty's LuaJIT and the other is built with official version of LuaJIT. I created two locations to set and get global variable like this:

location = /set {
    content_by_lua_block { key=1 ngx.say("set global key!") }
}
location / {
    content_by_lua_block { ngx.say(key or "nil")}
}

In the result, the OpenResty's LuaJIT version successfully got the gloabl 'key' and the other version did't.

So why does lua-nginx has this global environment setting with different luajit version? Why doesn't OpenResty's LuaJIT need isolated global environment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant