nginx init
2016-05-09 17:13:51 0 举报
nginx
作者其他创作
大纲/内容
# src/http/ngx_http_core_module.cngx_http_handler(ngx_http_request_t *r){ ... ngx_http_core_run_phases(r); ...}
ngx_connection_svoid *datangx_event_t *readngx_event_t *writengx_listening_t *listening
cycle = ngx_init_cycle(&init_cyle)
# event/ngx_event.cngx_int_t ngx_event_process_init(cycle){ ngx_event_timer_init() find module that config file using. module-actions.init(cycle) /* for each listening socket */ rev-handler = ngx_event_accept
if failed: rollback
os/unix/ngx_process_cycle.c void ngx_worker_process_init(){ for (i = 0; ngx_modules[i]; i++) ngx_modules[i]-init_process(cycle) ngx_add_channel_event()}
os/unix/ngx_process_cycle.c void ngx_worker_process_cycle(){ ngx_worker_process_init() ngx_setproctitle()
os/unix/ngx_process_cycle.cvoid ngx_master_process_cycle(){ ngx_setproctitle() ngx_start_worker_processes() ngx_start_garbage_collector() waiting for and process signals}
# http/ngx_http_request.cngx_http_process_request(ngx_http_request_t *r){ ... ngx_http_handler(r); ..}
ngx_daemon()ngx_create_pidfile()if master ngx_master_process_cycle();else ngx_single_process_cycle();
# http/ngx_http_request.cngx_http_init_request(){ rev-handler = ngx_http_process_request_line; r-read_event_handler = ngx_http_block_reading}
ngx_process_events(cycle) /* ngx_event_actions.process_events() */}
os/unix/ngx_process_cycle.cvoid ngx_start_worker_processes(){ ngx_spawn_process() /*ngx_worker_process_cycle*/ ngx_write_channel()}
# http/ngx_http.cvoid ngx_http_block(){ ... ls = ngx_listening_inet_stream_socket()
# http/ngx_http_request.cngx_http_process_request_headers(ngx_event_t *rev){ ... ngx_http_process_request(); ...}
ls-handler = ngx_http_init_connection}
ngx_open_listening_sockets(cycle)
new connection come
ngx_listening_s
# main() - core/nginx.cngx_time_init()ngx_log_init()ngx_cycle = &init_cycleinit_cycle.pool = ngx_create_pool()count ngx_max_module;
0 条评论
下一页