当前位置: 首页 > 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,代表 成功

 

相关文章:

  • 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 服务通信
  • 电子政务网站建设法律法规/搜索引擎优化服务
  • 购物网站 购物车界面如何做/推广赚钱app
  • 宣讲家网站两学一做心得体会/seo课程简介
  • 邯郸网站建设多少钱/微信营销号
  • finebi商业智能软件/seo霸屏
  • 深圳微信网站开发/网站的优化与推广分析