feature: support cosocket and other yieldable APIs in init_worker_by_lua* - #2521
Draft
tzssangglass wants to merge 1 commit into
Draft
feature: support cosocket and other yieldable APIs in init_worker_by_lua*#2521tzssangglass wants to merge 1 commit into
tzssangglass wants to merge 1 commit into
Conversation
tzssangglass
force-pushed
the
init-worker-cosocket-runner
branch
2 times, most recently
from
September 6, 2026 07:29
47e76c4 to
9b1ac2f
Compare
Enable TCP/UDP cosockets, ngx.sleep, ngx.semaphore, ngx.thread.spawn, coroutine.*, and ngx.run_worker_thread inside init_worker_by_lua* by running a bounded event pump when the init code yields. Key changes: - Add ngx_http_lua_init_worker_pump() to drive the event loop during yields - Add ngx_http_lua_init_worker_pump_loop() with timeout budget management - Add ngx_http_lua_init_worker_toggle_accept() to disarm/re-arm listeners around the pump (prevents level-triggered busy-spin from pending accepts) - Freeze ngx.timer.at registrations via ctx->context gate; flush at runner exit with absolute expiry preservation (timer ordering identical to before) - 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_HTTP_LUA_CONTEXT_YIELDABLE mask in util.h - Change runtime error prefix to "lua entry thread aborted:" (breaking) - Update README: new directives, cosocket availability, 118 API context lines
tzssangglass
force-pushed
the
init-worker-cosocket-runner
branch
from
September 6, 2026 10:19
9b1ac2f to
2eb7501
Compare
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, coroutine., and ngx.run_worker_thread inside init_worker_by_lua by running a bounded event pump when the init code yields.
Key changes:
I hereby granted the copyright of the changes in this pull request
to the authors of this lua-nginx-module project.
sister PR: openresty/stream-lua-nginx-module#409