我的小nginx模块遇到了一些麻烦(和头疼)。 我最近看过很多模块代码,还有很多关于nginx模块的东西,但是我无法做到我需要做的事情。 这是我的问题: 我创建了自己的名为“mymodule”的nginx模块。它的loc_conf结构如下所示:
typedef struct {
void *serverConf;
ngx_str_t server_file;
} ngx_http_mymodule_loc_conf_t;
它的命令结构如下:
static ngx_command_t ngx_http_mymodule_commands[] = {
{
ngx_string("mymodule"),
NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1,
ngx_http_mymodule,
NGX_HTTP_LOC_CONF_OFFSET,
0,
NULL
},
ngx_null_command
};
在ngx_http_mymodule函数中我做了一些事情并在ngx_http_mymodule_loc_conf_t中设置了serverConf指针。 问题是我想在退出线程/进程时检索该serverConf指针。但是在退出线程进程或主进程时给予ngx_module_t的唯一参数是ngx_cycle_t *,我无法找到如何从中检索ngx_http_mymodule_loc_conf_t以便处理该serverConf指针。
[编辑] 我已经在线程退出回调中尝试了这个,没有运气,因为有一个非null的serverConf指针:
ngx_http_mymodule_loc_conf_t *mymodulecf = (ngx_http_mymodule_loc_conf_t *)ngx_get_conf(cycle->conf_ctx, ngx_http_mymodule_module);
任何帮助或想法将不胜感激:)提前感谢。