ngx_conf_s

《Nginx高性能Web服务器详解》第11章Nginx基本数据结构,本章开始,我们学习Nginx源码的具体实现。学习体系错综复杂、功能服务实现丰富的Nginx服务器源码,应该从整个源码体系赖以存在的基本元素--数据结构开始学起。本节为大家介绍ngx_conf_s结构体。

作者:苗泽来源:电子工业出版社|2013-12-02 11:43

 收藏

  分享

11.9  ngx_conf_s结构体

该结构体用于Nginx在解析配置文件时描述每个指令的属性,也是Nginx程序中非常重要的一个数据结构,我们在/nginx/src/core/ngx_conf_file.h文件中可以找到它的定义:

 
  1. struct ngx_conf_s  {  
  2.     char                    *name;  
  3.     ngx_array_t             *args;  
  4.     ngx_cycle_t             *cycle;  
  5.     ngx_pool_t              *pool;  
  6.     ngx_pool_t              *temp_pool;  
  7.     ngx_conf_file_t         *conf_file;  
  8.     ngx_log_t               *log;   
  9.     void                    *ctx;   
  10.     ngx_uint_t              module_type;  
  11.     ngx_uint_t              cmd_type;   
  12.     ngx_conf_handler_pt     handler;  
  13.     char                    *handler_conf;  
  14. };  

*name,存放当前解析到的指令。

*args,存放该指令包含的所有参数。

*cycle,参见11.8节"ngx_cycle_s结构体"。

*pool,参见11.4节"ngx_pool_s结构体"。

*temp_pool,用于解析配置文件的临时内存池,解析完成后释放。其结构体类型的细节参见11.4节"ngx_pool_s结构体"。

*conf_file,存放Nginx配置文件的相关信息。ngx_conf_file_t结构体的定义我们在该文件中也能找到:

 
  1. typedef struct {  
  2.     ngx_file_t            file;                                     //文件的属性  
  3.     ngx_buf_t            *buffer;                                   //文件的内容  
  4.     ngx_uint_t            line;                                     //文件的行数  
  5. } ngx_conf_file_t;  

*log,描述日志文件的相关属性。

*ctx,描述指令的上下文。

module_type,支持该指令的模块的类型,core、http、event和mail中的一种。

cmd_type,指令的类型。

handler,指令自定义的处理函数。

*handler_conf,自定义处理函数需要的相关配置。

猜你喜欢

转载自blog.csdn.net/ai2000ai/article/details/83276083