欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 旅游 > ngx_conf_handler - root html

ngx_conf_handler - root html

2025/3/26 11:00:46 来源:https://blog.csdn.net/weixin_41812346/article/details/146476856  浏览:    关键词:ngx_conf_handler - root html
static ngx_int_t
ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last)
{char           *rv;void           *conf, **confp;ngx_uint_t      i, found;ngx_str_t      *name;ngx_command_t  *cmd;name = cf->args->elts;found = 0;

此时 name->data=root

    for (i = 0; cf->cycle->modules[i]; i++) {cmd = cf->cycle->modules[i]->commands;if (cmd == NULL) {continue;}for ( /* void */ ; cmd->name.len; cmd++) {if (name->len != cmd->name.len) {continue;}if (ngx_strcmp(name->data, cmd->name.data) != 0) {continue;}found = 1;

 循环查找 root 指令

直到 i=9

modules[9]->name=ngx_http_core_module

找到 了 root 指令

root 指令 用于指定 Nginx 服务器在响应请求时,查找静态文件的根路径

            else if (cf->ctx) {confp = *(void **) ((char *) cf->ctx + cmd->conf);if (confp) {conf = confp[cf->cycle->modules[i]->ctx_index];}}

此时

cmd->conf=16
ctx_index=0

ngx_http_conf_ctx_t -CSDN博客

cf->ctx + cmd->conf ,跳过前 2 个字段,指向第3个字段 loc_conf

根据索引在 数组中取出指针,它指向该 模块在 location 级对应的配置结构体

rv = cmd->set(cf, cmd, conf);

调用当前指令的 set 函数指针指向的函数,处理该指令的配置

当前 是 ngx_http_core_module 模块的 root 指令

set 指向的是 ngx_http_core_root 函数

ngx_http_core_root-CSDN博客

            if (rv == NGX_CONF_OK) {return NGX_OK;}

 返回 NGX_OK

 

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词