modules

ngx_conf_file.c -> 配置模块
ngx_log.c -> log
ngx_event.c -> event & event_core
ngx_http.c -> http
nginx.c -> core 

cycle

ngx_cycle.c ngx_cycle_t 
   -> conf_ctx ---> []ngx_event_module_t
   -> ngx_connection.h listening -> handler
ngx_core_module_t
   -> create_conf
   -> init_conf
ngx_module_s
   ctx --> nginx_core_module_t
       |
       |-> nginx_event_module_t
       |        actions
   init_module
   init_process
main
  ngx_master_process_cycle
    ngx_start_worker_processess
      ngx_worker_process_cycle
  ngx_init_signals --> 注册signal
  ngx_process_cycle.c
     sig_atomic_t  ngx_terminate

event

ngx_event_s
  ngx_event_handler_pt  handler;
  ngx_event_process_init
    module->actions.init(cycle, ngx_timer_resolution
      --> ngx_epoll_init
     for (i = 0; i < cycle->listening.nelts; i++) {¬
         rev->handler = (c->type == SOCK_STREAM) ? ngx_event_accept
         

accept

ngx_event_accept
   ls->handler(c);


worker

      ngx_worker_process_cycle
      for()
        ngx_process_events_and_timers

http

ngx_http_core_main_conf_t
  ngx_http_phase_engine_t
  ngx_http_phase_t
ngx_http_request_s
    phase_handler

ngx_http_commands -> 
ngx_http_block
ngx_http_init_phase_handlers
checker = ngx_http_core_generic_phase
ngx_http_block
ngx_http_optimize_servers
ngx_http_init_listening
ngx_http_add_listening
ngx_http_init_connection
-> ngx_http_wait_request_handler
size = cscf->client_header_buffer_size
ngx_http_process_request_line
    rev->handler = ngx_http_process_request_headers
    ngx_http_process_request_headers
        ngx_http_process_request
            c->read->handler = ngx_http_request_handler;
            ngx_http_request_handler
                if (ev->write) {
                    r->write_event_handler(r);
                } else {
                    r->read_event_handler(r);
                }
            c->write->handler = ngx_http_request_handler;
            r->read_event_handler = ngx_http_block_reading;
            ngx_http_handler
                r->write_event_handler = ngx_http_core_run_phases
                ngx_http_core_run_phases
            ngx_http_run_posted_requests
ngx_http_parse_request_line
ngx_http_process_request_uri

access http

ngx_http_access_module_ctx ->
ngx_http_access_init
    h = ngx_array_push(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers);
    if (h == NULL) {
        return NGX_ERROR;
    }

    *h = ngx_http_access_handler;