到进程获得了监听锁的时候,就会调用ngx_enable_accept_events函数,我们来看看这个函数作什么事情:
主要是遍历listen,调用ngx_add_event函数,这个函数定义
#define ngx_add_event ngx_event_actions.add
我们在看看这个ngx_event_actions从哪里来的,在ngx_epoll_init函数中,我们看到
ngx_event_actions = ngx_epoll_module_ctx.actions;
那么看下 ngx_epoll_module_ctx :
所以,ngx_add_event 实际就是调用了 ngx_epoll_add_event 函数,把socket添加到epoll中。