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

ngx_cycle_modules

Ubuntu 下 nginx-1.24.0 源码分析 - ngx_cycle_modules-CSDN博客 


定义在 src/core/ngx_module.c
ngx_int_t
ngx_cycle_modules(ngx_cycle_t *cycle)
{
    /*
     * create a list of modules to be used for this cycle,
     * copy static modules to it
     */

    cycle->modules = ngx_pcalloc(cycle->pool, (ngx_max_module + 1)
                                              * sizeof(ngx_module_t *));
    if (cycle->modules == NULL) {
        return NGX_ERROR;
    }

    ngx_memcpy(cycle->modules, ngx_modules,
               ngx_modules_n * sizeof(ngx_module_t *));

    cycle->modules_n = ngx_modules_n;

    return NGX_OK;
}

    cycle->modules = ngx_pcalloc(cycle->pool, (ngx_max_module + 1)
                                              * sizeof(ngx_module_t *));
    if (cycle->modules == NULL) {
        return NGX_ERROR;
    }
在 cycle 的内存池中分配内存,存储模块指针数组

ngx_max_module + 1:ngx_max_module 是最大模块数,+1 用于预留终止标记( NULL)


    ngx_memcpy(cycle->modules, ngx_modules,
               ngx_modules_n * sizeof(ngx_module_t *));

 将全局模块数组 ngx_modules 拷贝到 cycle->modules


cycle->modules_n = ngx_modules_n;
将全局模块数量 ngx_modules_n 赋值给 cycle->modules_n

return NGX_OK;

返回 NGX_OK,代表 成功

 

http://www.dtcms.com/a/120058.html

相关文章:

  • this指针 和 类的继承
  • Django异步执行任务django-background-tasks
  • 下一代智能爬虫框架:ScrapeGraphAI 详解
  • 第一章 react redux的学习,单个reducer
  • macOS Chrome - 打开开发者工具,设置 Local storage
  • nginx 代理 https 接口
  • Ubuntu虚拟机编译安装部分OpenCV模块方法实现——保姆级教程
  • Corrective Retrieval Augmented Generation
  • GitHub 趋势日报 (2025年04月04日)
  • 【区块链安全 | 第二十九篇】合约(三)
  • 需求的图形化分析-状态转换图
  • 【C++算法】51.链表_两数相加
  • 【论文粗读】Multi-scale Neighbourhood Feature Interaction Network
  • ruby高级语法
  • Linux命令学习
  • export default function?在react中在前面还是后面呢?
  • node.js之path常用方法
  • 模仿axios的封装效果来封装fetch,实现baseurl超时等
  • 批量将图片转换为 jpg/png/Word/PDF/Excel 等其它格式
  • 【ROS 通信】Services 服务通信
  • pinia中不定义state和action也能正常使用属性和方法
  • [Effective C++]条款28:避免返回handles指向对象内部成分
  • AI 智能外呼系统的智能体现
  • Python语言的网络编程
  • 大模型FAQ
  • C++-Mongoose(2)-https-server-openssl
  • Java核心技术面试题
  • micro ubuntu 安装教程
  • 【亲测】Linux 使用 Matplotlib 显示中文
  • Solidity入门实战—web3