In nginx, during parsing the configure file the function ngx_mail_block() is called. The function ngx_mail_block() allocate buffer for main configure information and server configure information. At one time the create_main_conf() and the create_srv_conf() hooks in all mail module are invoked. And so on, the init_main_conf() and the merge_srv_conf() are both called. At the end of the function ngx_mail_block(), ngx_mail_optimize_servers() is called.
In the function ngx_mail_optimize_servers(), the following code is so important.
...
ls = ngx_create_listening(cf, addr[i].sockaddr, addr[i].socklen);
if (ls == NULL) {
return NGX_CONF_ERROR;
}
ls->addr_ntop = 1;
ls->handler = ngx_mail_init_connection;
ls->pool_size = 256;
...
The ngx_mail_init_connection() is set. OK. The function ngx_mail_init_connection() is started for a connection.
The above is for the mail module. The http module is similar to it.