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

WBOY
Libérer: 2016-08-08 09:24:45
original
1016 Les gens l'ont consulté

处理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);
Copier après la connexion

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


以上就介绍了[nginx源码解析]配置解析(event作用域),包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!