当前位置: 首页 > article >正文

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

 


http://www.kler.cn/a/611564.html

相关文章:

  • GPT Researcher 的win docker安装攻略
  • unity泛型对象池
  • Elasticsearch:使用 AI SDK 和 Elastic 构建 AI 代理
  • JVM
  • Occlum 是一个内存安全的、支持多进程的 library OS,特别适用于 Intel SGX。
  • 基于VMware虚拟机的Ubuntu22.04系统安装和配置(新手保姆级教程)
  • b站视频字幕提取拓展推荐
  • 腾讯四面面经
  • 架构思路法
  • 批量给 PDF 页面添加超链接
  • Android 自定义变形 SHA1 算法
  • 【含文档+PPT+源码】基于SpringBoot+Vue的贫困地区留守儿童关怀系统
  • React多层级对象改变值--immer
  • [leetcode]map和unodered_map的使用场景
  • 精品推荐-2025全固态电池会议演讲嘉宾(脱敏)PPT合集(30份).zip
  • Golang 容易被忽视的知识点(个人向)
  • 如何在1分钟内编写Cursorrules
  • 智慧路灯机器人是否支持远程监控和管理?
  • 工单分类总结
  • Photoshop 2025 Mac中文 Ps图像编辑