Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Analysis of event module initialization source code of nginx

Shulou Source: shulou.com Published: 2022-06-01 14:46:42 09月26日 Update

This article mainly introduces "nginx event module initialization source code analysis". In daily operation, I believe that many people have doubts about nginx event module initialization source code analysis. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "nginx event module initialization source code analysis". Next, please follow the editor to study!

Let's take a look at the code for the create_conf functions of each module.

This is the create_conf function of the ngx_event_core_module module.

/ / create a structure to store the event module configuration

Static void * ngx_event_create_conf (ngx_cycle_t * cycle)

{

Ngx_event_conf_t * ecf

Ngx_test_null (ecf, ngx_palloc (cycle- > pool, sizeof (ngx_event_conf_t))

NGX_CONF_ERROR)

Ecf- > connections = NGX_CONF_UNSET_UINT

Ecf- > use = NGX_CONF_UNSET_UINT

Ecf- > multi_accept = NGX_CONF_UNSET

Ecf- > accept_mutex = NGX_CONF_UNSET

Ecf- > accept_mutex_delay = NGX_CONF_UNSET_MSEC

Ecf- > name = (void *) NGX_CONF_UNSET

# if (NGX_DEBUG)

Ngx_init_array (ecf- > debug_connection, cycle- > pool, 5, sizeof (in_addr_t))

NGX_CONF_ERROR)

# endif

Return ecf

}

The remaining eventful submodules are event-driven, and the create_conf function of epoll is as follows.

Static void * ngx_epoll_create_conf (ngx_cycle_t * cycle)

{

Ngx_epoll_conf_t * epcf

Ngx_test_null (epcf, ngx_palloc (cycle- > pool, sizeof (ngx_epoll_conf_t))

NGX_CONF_ERROR)

Epcf- > events = NGX_CONF_UNSET

Return epcf

}

Kqueue's are as follows.

Static void * ngx_kqueue_create_conf (ngx_cycle_t * cycle)

{

Ngx_kqueue_conf_t * kcf

Ngx_test_null (kcf, ngx_palloc (cycle- > pool, sizeof (ngx_kqueue_conf_t))

NGX_CONF_ERROR)

Kcf- > changes = NGX_CONF_UNSET

Kcf- > events = NGX_CONF_UNSET

Return kcf

}

Some sub-modules do not implement the create_conf function, after the create_conf function of all modules is executed.

At this point, on the "nginx event module initialization source code analysis" on the end of the study, I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Modules functions source code analysis learning events more help practical next code articles methods theory knowledge articles structures websites materials follow Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei MySQL MariaDB Apple Shulou Tech Info