热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Nginx模块加载源码分析

所在需要加载的模块名数组:char*ngx_module_names[]{ngx_core_module,ngx_errlog_module,ngx_co

所在需要加载的模块名数组:

char *ngx_module_names[] = {"ngx_core_module","ngx_errlog_module","ngx_conf_module",…………"ngx_http_module"…………
}ngx_module_t *ngx_modules[] = {&ngx_core_module,&ngx_errlog_module,&ngx_conf_module,&ngx_regex_module,&ngx_events_module,&ngx_event_core_module,&ngx_epoll_module,&ngx_thread_pool_module,&ngx_http_module,&ngx_http_core_module,&ngx_http_log_module,&ngx_http_upstream_module,&ngx_http_static_module,&ngx_http_autoindex_module,&ngx_http_index_module,&ngx_http_mirror_module,&ngx_http_try_files_module,&ngx_http_auth_basic_module,&ngx_http_access_module,&ngx_http_limit_conn_module,&ngx_http_limit_req_module,&ngx_http_geo_module,&ngx_http_map_module,&ngx_http_split_clients_module,&ngx_http_referer_module,&ngx_http_rewrite_module,&ngx_http_proxy_module,&ngx_http_fastcgi_module,&ngx_http_uwsgi_module,&ngx_http_scgi_module,&ngx_http_memcached_module,&ngx_http_empty_gif_module,&ngx_http_browser_module,&ngx_http_upstream_hash_module,&ngx_http_upstream_ip_hash_module,&ngx_http_upstream_least_conn_module,&ngx_http_upstream_random_module,&ngx_http_upstream_keepalive_module,&ngx_http_upstream_zone_module,&ngx_http_write_filter_module,&ngx_http_header_filter_module,&ngx_http_chunked_filter_module,&ngx_http_range_header_filter_module,&ngx_http_gzip_filter_module,&ngx_http_postpone_filter_module,&ngx_http_ssi_filter_module,&ngx_http_charset_filter_module,&ngx_http_userid_filter_module,&ngx_http_headers_filter_module,&ngx_http_copy_filter_module,&ngx_http_range_body_filter_module,&ngx_http_not_modified_filter_module,NULL
};//http 模块结构体
//NGX_MODULE_V1 宏定义包含了name字段,是一个空指针,ngx_preinit_modules函数会将ngx_module_names中的字符串赋值给它
//系统初始化时解析配置,解析到ngx_http_commands中对应的指令,会调ngx_http_commands中的set回调函数
ngx_module_t ngx_http_module = {NGX_MODULE_V1,&ngx_http_module_ctx, /* module context */ngx_http_commands, /* module directives */NGX_CORE_MODULE, /* module type */NULL, /* init master */NULL, /* init module */NULL, /* init process */NULL, /* init thread */NULL, /* exit thread */NULL, /* exit process */NULL, /* exit master */NGX_MODULE_V1_PADDING
};//nginx启动时解析配置,解析到"http"时,会调用ngx_http_block
static ngx_command_t ngx_http_commands[] = {{ ngx_string("http"),NGX_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,ngx_http_block,0,0,NULL },ngx_null_command
};

以HTTP模块为例分析: 

main
|
|__ngx_preinit_modules //用ngx_module_names列出的模块名,初始化ngx_modules[]结构体数组
|
|__ngx_init_cycle||__ngx_cycle_modules //将ngx_modules[]拷贝到cycle->modules||__ngx_conf_parse| || |__ngx_conf_handler| || |__ngx_http_block//HTTP 模块的入口函数||__ngx_init_modules//调用 ngx_module_t 结构中的init_module回调函数

 


推荐阅读
  • crossorigin注解添加了解决不了跨域问题_CORS与@CrossOrigin详解
    1、跨域的基本概念a、跨域的解释要了解跨域,首先需要知晓浏览器的同源策略,简单的说就是两个请求协议、端口、主机都相同,则两个请求具有相同的 ... [详细]
  • PNG在IE6下透明问题的解决办法
    2019独角兽企业重金招聘Python工程师标准做Web开发的朋友一定都知道PNG是一个相当不错的图片格式,但是这个好的格式却在IE6时代造成了麻烦࿰ ... [详细]
  • 1、为什么要对nginx平滑升级随着nginx越来越流行,并且nginx的优势也越来越明显,nginx的版本迭代也来时加速模式,1.9. ... [详细]
  • 贴图的支持及设置:关于贴图分辨率的支持及设置的用户指南
    http:hi.baidu.comdbfr2011818itemeef1eac8df31a2d69744520b贴图分辨率虚幻引擎3支持的贴图分辨率是从1x1到4096x4096 ... [详细]
  • delphi控件大全
    本文章已收录于:delphi控件查询:http:www.torry.nethttp:www.jrsoftware.orgTb97最有名的工具条(ToolBar) ... [详细]
  • Flex中使用filter过滤数据 ... [详细]
  • 图像处理(7) : 边缘检测
    边缘检测是图形图像处理、计算机视觉和机器视觉中的一个基本工具,通常用于特征提取和特征检测,旨在检测一张数字图像中有明显变化的边缘或者不连续的区域 ... [详细]
  • 最近学习了数据挖掘常用的两种算法:FP-Growth和K-Means。现在把我的学习结果分享给大家。以下是本文的目录,大家可以根据需要跳过一些章节:1.FP-Grow ... [详细]
  • JS加密解密
    leta=汪政..222RRRp767868^*%^*%344h哈哈;letb=udp.d(ud(a));//需要加密的内容letc=udp. ... [详细]
  • 本文由编程笔记#小编为大家整理,主要介绍了markdownElasticsearch:更新现有索引的映射和设置相关的知识,希望对你有一定的参考价值。 ... [详细]
  • 缓存的重要性就不用再强调了,@OutputCache给我们提供了一种声明的方式(对应的还有编程的方式)来控制页面和用户控件的缓存策略,这是一种最简单直接的网站优化方式。还是先来过一遍@ ... [详细]
  • 一、过滤器1.1概述(1)过滤器(Filters)提供了一种执行文本转换的方法,比如说都转换成大写字母或者几乎 ... [详细]
  • 使用ffmpeg进行视频格式转换的简单例子2006-12-1623:12主要参考FFMPEG里面的apiexample.c以及output_example.c编写intmain(in ... [详细]
  • 安全等于运算符()这个操作符和操作符执行相同的比较操作,不过可以用来判断NULL值。在两个操作数均为NULL时,其返回值为1而不为NULL;而当一个操作数为NULL时,其返回 ... [详细]
  • 服务器性能优化之网络性能优化
    hi,大家好,今天分享一篇后台服务器性能优 ... [详细]
author-avatar
mobiledu2502861133
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有