这个函数做了连部分工作:1)以端口为入口点 将有用的信息存放到hash表内 2)调用ngx_http_init_listening()函数 对端口进行监听
1、 在ngx_http_core_main_conf_t结构体中有一个字段为ports,是一个数组,数组内存放的全是ngx_http_conf_port_t;对于每一个端口信息(ngx_http_conf_port_t),调用
ngx_http_server_names函数,同时也调用ngx_http_init_listening函数,这里先分析ngx_http_server_names函数。
2)对于每一个端口信息(ngx_http_conf_port_t),里面有一个字段为addrs,这个字段是一个数组,这个数组内存放的全是地址信息(ngx_http_conf_addr_t),一个地址信息
(ngx_http_conf_addr_t)对应着多个server{}配置块(ngx_http_core_srv_conf_t)3
3)对于每一个server{}配置块信息(ngx_http_core_srv_conf_t)对应着很多个sever_name.所以,ngx_http_core_srv_conf_t结构体中有一个数组server_names,成员是ngx_http_server_name_t,这样对每个server_name(ngx_http_server_name_t)进行操作,存放到hash表内
这样就完成了以端口(ngx_http_conf_port_t)为入口点 对所有的地址都进行遍历,将所有的server_name都存放到hash表内
二、ngx_http_init_listening()函数调用
在ngx_http_core_main_conf_t结构体中存放着一个Port信息的数组,对于每一个port进行ngx_http_init_listening 的操作,对每一个ngx_http_conf_addr_t信息调用
ngx_http_add_listening