The data structure of nginx important

struct ngx_module_s {
//Ctx_index is the module counter classification, the nginx module can be divided into four types: core, event, HTTP and
//mail, Each module will each count, the ctx_index is each module numerical in its class group

ngx_uint_t ctx_index;

//Index is a module counter, according to each module in the ngx_modules[] array statement sequence
//(see objs/ngx_modules.c), began to turn to each module are numbered from 0
ngx_uint_t index;

/*...*/
ngx_uint_t version;

//CTX is the module of context, different modules have different context, four kinds of module four module context, for four different structure, so the CTX is void *
void *ctx;

//Commands is a set of instructions for each module, nginx module can achieve some custom instruction, the instruction
//Write the appropriate configuration items in the configuration file, each instruction in the source code corresponding to a ngx_command_t structure
//Variable, nginx will read module instruction out commands instruction array in module from the configuration file,
//These instructions are usually the parameter configuration of the value assigned to some program variables or between different variables associated with or
//Conversion data (such as include directive), instruction can take parameters can also be with no parameters, you can use these commands to imagine
//UNIX command line or a template language instruction.
ngx_command_t *commands;

//Type type is the module, as has been noted, the nginx module is divided into core, event, HTTP and mail four, type for macro definition identifies four categories.
ngx_uint_t type;

//init_master, init_module, init_process, init_thread, exit_thread,
//exit_process, Exit_master is a function pointer, pointing to a custom callback function module,
//The callback function respectively in the initialization of master, initialization module, initialization process, initialization thread,
//Quit, quit working process and thread exit when master is invoked, if the module needs to do in these times,
//Function can implement the corresponding, and assign it to the corresponding function pointer to register a callback function interface
ngx_int_t (*init_master)(ngx_log_t *log);
ngx_int_t (*init_module)(ngx_cycle_t *cycle);
ngx_int_t (*init_process)(ngx_cycle_t *cycle);
ngx_int_t (*init_thread)(ngx_cycle_t *cycle);
void (*exit_thread)(ngx_cycle_t *cycle);
void (*exit_process)(ngx_cycle_t *cycle);
void (*exit_master)(ngx_cycle_t *cycle);

/*...*/

};




struct ngx_cycle_s {
void ****conf_ctx; //Configure context array (including all modules)
ngx_pool_t *pool; //Memory pool

ngx_log_t *log; //Journal
ngx_log_t new_log;

ngx_connection_t **files; //The connection file
ngx_connection_t *free_connections; //Idle connections
ngx_uint_t free_connection_n; //Idle connection number

ngx_queue_t reusable_connections_queue; //The connection queue

ngx_array_t listening; //Monitoring array
ngx_array_t pathes; //Path array
ngx_list_t open_files; //Open the file list
ngx_list_t shared_memory; //Shared memory list

ngx_uint_t connection_n; //Connection number
ngx_uint_t files_n; //Open the file number

ngx_connection_t *connections; //Connect
ngx_event_t *read_events; //Read events
ngx_event_t *write_events; //Write event

ngx_cycle_t *old_cycle; //Old cycle pointer

ngx_str_t conf_file; //The configuration file
ngx_str_t conf_param; //Configuration parameter
ngx_str_t conf_prefix; //Configure prefix
ngx_str_t prefix; //Prefix
ngx_str_t lock_file; //Lock file
ngx_str_t hostname; //Host name
};



Posted by Antony at March 23, 2014 - 6:31 AM