Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ behavior.
* [init_by_lua_file](https://github.com/openresty/lua-nginx-module#init_by_lua_file)
* [init_worker_by_lua_block](https://github.com/openresty/lua-nginx-module#init_worker_by_lua_block)
* [init_worker_by_lua_file](https://github.com/openresty/lua-nginx-module#init_worker_by_lua_file)
* [lua_init_worker_timeout](https://github.com/openresty/lua-nginx-module#lua_init_worker_timeout)
* [lua_init_worker_abort_on_error](https://github.com/openresty/lua-nginx-module#lua_init_worker_abort_on_error)
* [preread_by_lua_block](#preread_by_lua_block)
* [preread_by_lua_file](#preread_by_lua_file)
* [content_by_lua_block](https://github.com/openresty/lua-nginx-module#content_by_lua_block)
Expand Down Expand Up @@ -179,6 +181,19 @@ behavior.
* [lua_capture_error_log](https://github.com/openresty/lua-nginx-module#lua_capture_error_log)
* [preread_by_lua_no_postpone](#preread_by_lua_no_postpone)

Cosockets (and other yieldable APIs) are supported in `init_worker_by_lua*`.
When a cosocket operation yields (for example, during a `connect` or
`receive` call), the module runs a lightweight event pump that drives the
Nginx event loop until the operation completes. See
[lua_init_worker_timeout](https://github.com/openresty/lua-nginx-module#lua_init_worker_timeout)
and
[lua_init_worker_abort_on_error](https://github.com/openresty/lua-nginx-module#lua_init_worker_abort_on_error)
in ngx_http_lua for the directives that bound how long the init code may
block worker startup and how Lua runtime errors are handled.

Note that `ngx.timer.at` callbacks registered during `init_worker_by_lua*`
are deferred: they will not run until the init code finishes.

The [send_timeout](https://nginx.org/r/send_timeout) directive in the Nginx
"http" subsystem is missing in the "stream" subsystem. As such,
ngx_stream_lua_module uses the `lua_socket_send_timeout` directive for this
Expand Down
4 changes: 4 additions & 0 deletions src/ngx_stream_lua_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ struct ngx_stream_lua_main_conf_s {
ngx_stream_lua_main_conf_handler_pt init_worker_handler;
ngx_str_t init_worker_src;

ngx_msec_t init_worker_timeout;
ngx_flag_t init_worker_abort_on_error;
ngx_queue_t deferred_timers;

ngx_stream_lua_balancer_peer_data_t *balancer_peer_data;
/* neither yielding nor recursion is possible in
* balancer_by_lua*, so there cannot be any races among
Expand Down
Loading
Loading