nginx add listen sock to epoll

来源:互联网 发布:java中构造器的作用 编辑:程序博客网 时间:2024/05/17 10:05

      到进程获得了监听锁的时候,就会调用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中。

 

 

原创粉丝点击