[nginx源码解析]配置解析(event作用域)

处理events


其中符合NGX_EVENT_MODULE有两个模块分别是ngx_event_core_module、ngx_epoll_module

核心代码

  ngx_modules[i]->ctx_index = ngx_event_max_module++;//设置模块内部索引
      }                                                                                                                                                             
  
      ctx = ngx_pcalloc(cf->pool, sizeof(void *));
      if (ctx == NULL) {
          return NGX_CONF_ERROR;
      }
  
      *ctx = ngx_pcalloc(cf->pool, ngx_event_max_module * sizeof(void *));//ctx指向数组
      if (*ctx == NULL) {
          return NGX_CONF_ERROR;
      }
  
      *(void **) conf = ctx;
  
      for (i = 0; ngx_modules[i]; i++) {
          if (ngx_modules[i]->type != NGX_EVENT_MODULE) {
              continue;
          }
  
          m = ngx_modules[i]->ctx;
  
          if (m->create_conf) {//如果NGX_EVENT_MODULE类型模块存在create_conf函数那么就调用该模块的create_conf函数,挂载到event上下文中
              (*ctx)[ngx_modules[i]->ctx_index] = m->create_conf(cf->cycle);//创建相应上下文
              if ((*ctx)[ngx_modules[i]->ctx_index] == NULL) {
                  return NGX_CONF_ERROR;
              }
          }
      }
  
      pcf = *cf;
      cf->ctx = ctx;
      cf->module_type = NGX_EVENT_MODULE;//设置模块环境
      cf->cmd_type = NGX_EVENT_CONF;		//设置命令类型
rv = ngx_conf_parse(cf, NULL);

然后解析worker_connections1024,该命令在ngx_event_core_module中,调用ngx_event_connections函数,设置connect值为1024,结构如下:



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值