ngx_conf_s 迈不过友情╰ 2022-05-04 06:58 59阅读 0赞 《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,自定义处理函数需要的相关配置。
还没有评论,来说两句吧...