core模块的初始化

1.core模块的配置结构:
typedef struct {
ngx_flag_t daemon;
ngx_flag_t master;

 ngx_msec_t               timer_resolution;  

 ngx_int_t                worker_processes;  
 ngx_int_t                debug_points;  

 ngx_int_t                rlimit_nofile;  
 ngx_int_t                rlimit_sigpending;  
 off_t                    rlimit_core;  

 int                      priority;  

 ngx_uint_t               cpu_affinity_n;  
 u_long                  *cpu_affinity;  

 char                    *username;            /* 用户名 */  
 ngx_uid_t                user;                /* user ID */  
 ngx_gid_t                group;               /* group ID*/  

 ngx_str_t                working_directory;   /*  */  
 ngx_str_t                lock_file;           /* 用户名 */  

 ngx_str_t                pid;  
 ngx_str_t                oldpid;              /* 以'.oldbin'结尾 */  

 ngx_array_t              env;  
 char                   **environment;  
 ngx_int_t                worker_threads;  
 size_t                   thread_stack_size;  

} ngx_core_conf_t;
//core模块的create_conf创建的结构体,存放很多重要的指令
2.create_conf:
它只是一个指针,指向ngx_core_module_init_conf()函数,主要用于创建ngx_core_conf_t结构体,并且对该结构体中的其他字段,一般是值为-1的宏
3.init_conf:
它才是真正的初始化该结构体
1》初始化daemon.master
2》调用ngx_conf_full_name初始化pid,lock_file,实际上就是在pid字符串前面加上NGX_PREFIX,
3》初始化username user group
通过系统调用getpwnam()和getgrnam()完成

猜你喜欢

转载自blog.csdn.net/wellwang1993/article/details/51163221