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

ngx_lua: support ngx_lua custom coroutine's fun #99

Closed
wants to merge 1 commit into from

Conversation

detailyang
Copy link

Hello

@mpeterv

Now the newest luacheck 0.19.0 redefines the ngx_lua standard and it will make the CI failed because of accessing undefined field _yield of global coroutine in lua-resty-core

OpenResty inject the custom API to coroutine table as the following:

    lua_getglobal(L, "coroutine");

    /* set running to the old one */
    lua_getfield(L, -1, "running");
    lua_setfield(L, -3, "running");

    lua_getfield(L, -1, "create");
    lua_setfield(L, -3, "_create");

    lua_getfield(L, -1, "resume");
    lua_setfield(L, -3, "_resume");

    lua_getfield(L, -1, "yield");
    lua_setfield(L, -3, "_yield");

    lua_getfield(L, -1, "status");
    lua_setfield(L, -3, "_status");

    /* pop the old coroutine */
    lua_pop(L, 1);

    lua_pushcfunction(L, ngx_http_lua_coroutine_create);
    lua_setfield(L, -2, "__create");

    lua_pushcfunction(L, ngx_http_lua_coroutine_resume);
    lua_setfield(L, -2, "__resume");

    lua_pushcfunction(L, ngx_http_lua_coroutine_yield);
    lua_setfield(L, -2, "__yield");

    lua_pushcfunction(L, ngx_http_lua_coroutine_status);
    lua_setfield(L, -2, "__status");

    lua_setglobal(L, "coroutine");

So add the coroutine fields to pass the CI.

@mpeterv
Copy link
Owner

mpeterv commented Mar 11, 2017

Hello @detailyang, are these extensions documented? The field list could be added to the standard so that typos like coroutine._yieldd are detected. But if there are not documented maybe the field list is not stable.

@detailyang
Copy link
Author

@mpeterv

As far as I know, these are not official document in OpenResty :(. But you know the code maybe is the best document although it could not stable.

Wish @agentzh can help us:)

@agentzh
Copy link

agentzh commented Mar 11, 2017

@detailyang Those were internal API functions and are undocumented by intention :) Use of those API functions by normal users are discouraged. I think maybe you should just whitelist those specifically in your own luacheck configuration file, if user whitelisting is supported in luacheck?

@detailyang
Copy link
Author

gotcha

@detailyang detailyang closed this Mar 12, 2017
@detailyang detailyang deleted the patch-1 branch March 13, 2017 03:07
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

Successfully merging this pull request may close these issues.

None yet

3 participants