ngx_http_scgi_create_main_conf

在 src\http\modules\ngx_http_scgi_module.c

复制代码
static void *
ngx_http_scgi_create_main_conf(ngx_conf_t *cf)
{
    ngx_http_scgi_main_conf_t  *conf;

    conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_scgi_main_conf_t));
    if (conf == NULL) {
        return NULL;
    }

#if (NGX_HTTP_CACHE)
    if (ngx_array_init(&conf->caches, cf->pool, 4,
                       sizeof(ngx_http_file_cache_t *))
        != NGX_OK)
    {
        return NULL;
    }
#endif

    return conf;
}

函数作用

ngx_http_scgi_create_main_conf 是 NGINX SCGI 模块的主配置创建函数。

其核心作用是:

分配并初始化模块的主配置结构:为 SCGI 模块创建一个配置对象(ngx_http_scgi_main_conf_t),用于存储模块的配置参数
初始化相关资源:根据编译时配置(如是否启用 HTTP 缓存),初始化必要的数据结构(如缓存数组)

函数逻辑

函数的执行流程如下:

步骤 1:分配内存

ngx_pcalloc 是 NGINX 的内存分配函数,从指定内存池 (cf->pool) 分配内存,作为 ngx_http_scgi_main_conf_t 结构体
步骤 2:初始化缓存数组(当启用 HTTP 缓存时)
条件编译:仅在编译时定义了 NGX_HTTP_CACHE(即启用 HTTP 缓存功能)时执行。
初始化 conf->caches 数组,用于存储缓存相关的指针(ngx_http_file_cache_t*)

相关推荐
小鱼小鱼.oO5 小时前
阿里云服务器安装nginx并配置前端资源路径(前后端部署到一台服务器并成功访问)
服务器·nginx·阿里云
广东数字化转型8 小时前
nginx怎么使用nginx-rtmp-module模块实现直播间功能
linux·运维·nginx
�FENG17 小时前
LVS、NGINX、HAPROXY的调度算法
nginx·lvs·haproxy·调度算法
哈哈哈哈哈哈哈哈哈...........21 小时前
【Nginx】使用 Nginx+Lua 实现基于 IP 的访问频率限制
tcp/ip·nginx·lua
Adorable老犀牛1 天前
负载均衡将https请求转发后端http服务报错:The plain HTTP request was sent to HTTPS port
nginx·http·https·负载均衡
�FENG2 天前
Nginx+Tomcat负载均衡与动静分离架构
nginx·tomcat·负载均衡·动静分离
别骂我h2 天前
Nginx+Tomcat负载均衡群集
nginx·tomcat·负载均衡
結城2 天前
使用nginx配置反向代理,负载均衡
运维·服务器·nginx
恋上钢琴的虫2 天前
搭建nginx的负载均衡
运维·nginx·负载均衡
FungLeo2 天前
安装和配置 Nginx 和 Mysql —— 一步一步配置 Ubuntu Server 的 NodeJS 服务器详细实录6
服务器·mysql·nginx