what's the proper way to get module specific configuration in init_process
shanlei at asiainfo.com
shanlei at asiainfo.com
Mon Jun 20 08:05:53 UTC 2022
Hello, guys,
Recently I have been working on an nginx c module, which have to
leverage on init_process routine.The logic is based on instruction
command which may be configured inside stream.server, I have to do some
work in the init_process routine, for example, to schedule a timer.
I did google a while ,and decide to using code snippet like below:
============================
ngx_stream_conf_ctx_t conf_ctx = (ngx_stream_conf_ctx_t
*)ngx_get_conf(cycle->conf_ctx, ngx_stream_module);
"module_spec_conf = conf_ctx->srv_conf["my_module".ctx_index];
=============================
However, the module_spec_conf I got is the top_level ,that is created
when nginx parse the stream section, not the one created when nginx
parse the stream.server section, the later has the proper values.
Currently to got the later structure, I have to copy the configure value
back from child to parent in configuration merger function, which is
inconvenient and buggy when the stream includes multi servers.
So I wonder what's the proper way to get module specific configuration
in the routine: init_process
Thanks
Lei
More information about the nginx-devel
mailing list