feature: support cosocket and other yieldable APIs in init_worker_by_lua* - #409
Draft
tzssangglass wants to merge 1 commit into
Draft
feature: support cosocket and other yieldable APIs in init_worker_by_lua*#409tzssangglass wants to merge 1 commit into
tzssangglass wants to merge 1 commit into
Conversation
Enable TCP/UDP cosockets, ngx.sleep, ngx.semaphore, ngx.thread.spawn, and coroutine.* inside init_worker_by_lua* by running a bounded event pump when the init code yields. Ported from ngx_http_lua_module and adapted to the stream subsystem. Key changes: - Add ngx_stream_lua_init_worker_pump() to drive the event loop during yields, including the posted delayed-events queue drain - Add ngx_stream_lua_init_worker_pump_loop() with timeout budget management - Add ngx_stream_lua_init_worker_toggle_accept() to disarm/re-arm listeners around the pump (prevents level-triggered busy-spin from pending accepts; mirrors nginx's reuseport/EPOLLEXCLUSIVE arming) - Freeze ngx.timer.at/every registrations via ctx->context gate; flush at runner exit with absolute expiry preservation (timer ordering identical to before) - Run the init chunk on an entry coroutine created with ngx_stream_lua_new_thread() on the global VM; finalize via finalize_fake_request on completion - Add lua_init_worker_timeout directive (default 0 = no timeout) - Add lua_init_worker_abort_on_error directive (default off) - Add INIT_WORKER to NGX_STREAM_LUA_CONTEXT_YIELDABLE mask in util.h - Change runtime error prefix to "lua entry thread aborted:" (breaking) - Update README: new directives and cosocket availability note
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enable TCP/UDP cosockets, ngx.sleep, ngx.semaphore, ngx.thread.spawn, and coroutine.* inside init_worker_by_lua* by running a bounded event pump when the init code yields. Ported from ngx_http_lua_module and adapted to the stream subsystem.
Key changes:
sister PR: openresty/lua-nginx-module#2521