In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "nginx http module initialization source code analysis". In daily operation, I believe that many people have doubts about nginx http 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 http module initialization source code analysis". Next, please follow the editor to study!
Continue the analysis of the http module, this time analyzing the execution of the init_module hook function. The init_module hooks of each sub-module of the http module mainly do two things, one is to register the phases callback, and the other is to mount the module to the filter linked list. First, take a look at the module that registers the phases callback
Access module
Static ngx_int_t ngx_http_access_init (ngx_cycle_t * cycle)
{
Ngx_http_handler_pt * h
Ngx_http_core_main_conf_t * cmcf
/ / remove the configuration structure of http_core_module
Cmcf = ngx_http_cycle_get_module_main_conf (cycle, ngx_http_core_module)
/ / callback set in NGX_HTTP_ACCESS_PHASE phase
H = ngx_push_array (& cmcf- > phases [NGX _ HTTP_ACCESS_PHASE] .handlers)
If (h = = NULL) {
Return NGX_ERROR
}
* h = ngx_http_access_handler
Return NGX_OK
}
Charset module
Static ngx_int_t ngx_http_charset_filter_init (ngx_cycle_t * cycle)
{
Ngx_http_next_header_filter = ngx_http_top_header_filter
Ngx_http_top_header_filter = ngx_http_charset_header_filter
Ngx_http_next_body_filter = ngx_http_top_body_filter
Ngx_http_top_body_filter = ngx_http_charset_body_filter
Return NGX_OK
}
The ngx_http_top_header_filter variable is a global variable defined in the ngx_http.c file. The ngx_http_next_header_filter variable is a visible local variable within a module defined by each filter module. Ngx_http_top_body_filter is similar. Each module orders its own next variable to execute the node that the current top variable points to, and then the top node points to the filter function of this module. As a result, a filter linked list is realized. When the filter hook of the current module is executed, the hook function finally executes the next hook corresponding to next.
At this point, on the "nginx http 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!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.