概述
nginx是事件驱动的, 事件主要来源于 1: i/o网络事件 2: 定时器事件. 事件驱动模型有三个部分: 1: 事件的收集 2: 事件分发 3: 事件处理
模块接口
ngx_module_t: 是nginx模块中最基本的接口, 对于每一种不同类型的模块, 都有具体的类型来描述其通用接口, 并且有nginx_module_t的ctx来管理
ngx_event_module_t: 事件模块的通用接口
ngx_event_actions_t: 事件驱动模块的具体接口, 主要是i/o多路复用的有关接口
ngx_event_t : 具体事件的定义, 以及定义事件发生时的回调函数
ngx_connection_t: 被动接受连接的结构体
ngx_peer_connection_s: 主动发起连接的结构体
所有事件模块的配置项管理
Nginx 服务器在结构体 ngx_cycle_t 中定义了一个四级指针成员 conf_ctx
模块间调用方法
是以职责链的方式依次调用
具体实现: next_publish是本模块的静态变量, ngx_rtmp_publish是全局变量
用ngx_rtmp_publish保存本模块的具体实现, 然后在下一个模块中的Postconfiguration函数中将其赋给本地变量next_publish
Postconfiguration(){
next_publish = ngx_rtmp_publish;
ngx_rtmp_publish = ngx_rtmp_hls_publish;
}