当前位置: 首页 > news >正文

襄阳市网站建设_网站建设公司_后端开发_seo优化

易语言做电影网站源码,南通科技网站建设,北京网络公司信息,网站建设五行属什么前言 在分析源码时,我们可以先把握主干,然后其他部分再挨个分析就行了。接下来我们先看看nginx的main函数干了些什么。 main函数 这里先介绍一些下面会遇到的变量类型: ngx_int_t: typedef intptr_t ngx_int_t; 64位机器上,intptr_t为long int, 即typedef long int intptr_…前言 在分析源码时,我们可以先把握主干,然后其他部分再挨个分析就行了。接下来我们先看看nginx的main函数干了些什么。 main函数 这里先介绍一些下面会遇到的变量类型: ngx_int_t: typedef intptr_t ngx_int_t; 64位机器上,intptr_t为long int, 即typedef long int intptr_t;在32位机器上,intptr_t为int,即typedef int intptr_t。 ngx_log_t: typedef struct ngx_log_s ngx_log_t,struct ngx_log_s存储了日志文件的各种信息 ngx_cycle_t是很重要的结构体,等下列出它的定义。 ngx_core_conf_t是core模块存储配置项的结构体。 ngx_core_conf_t是core模块存储配置项的结构体。 /* src/core/nginx.c */int ngx_cdecl main(int argc, char *const *argv) {ngx_int_t i;ngx_log_t *log;ngx_cycle_t *cycle, init_cycle;ngx_core_conf_t *ccf;#if (NGX_FREEBSD)ngx_debug_init(); #endifif (ngx_strerror_init() ! NGX_OK) {return 1;}//处理参数,设置对应的标识位等if (ngx_get_options(argc, argv) ! NGX_OK) {return 1;}//根据标识位显示版本、测试配置等if (ngx_show_version) {ngx_write_stderr(nginx version: NGINX_VER NGX_LINEFEED);if (ngx_show_help) {ngx_write_stderr(Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives] NGX_LINEFEEDNGX_LINEFEEDOptions: NGX_LINEFEED -?,-h : this help NGX_LINEFEED -v : show version and exit NGX_LINEFEED -V : show version and configure options then exitNGX_LINEFEED -t : test configuration and exit NGX_LINEFEED -q : suppress non-error messages during configuration testing NGX_LINEFEED -s signal : send signal to a master process: stop, quit, reopen, reload NGX_LINEFEED #ifdef NGX_PREFIX -p prefix : set prefix path (default: NGX_PREFIX ) NGX_LINEFEED #else -p prefix : set prefix path (default: NONE) NGX_LINEFEED #endif -c filename : set configuration file (default: NGX_CONF_PATH ) NGX_LINEFEED -g directives : set global directives out of configuration file NGX_LINEFEED NGX_LINEFEED);}if (ngx_show_configure) {ngx_write_stderr( #ifdef NGX_COMPILERbuilt by NGX_COMPILER NGX_LINEFEED #endif #if (NGX_SSL) #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAMETLS SNI support enabled NGX_LINEFEED #elseTLS SNI support disabled NGX_LINEFEED #endif #endifconfigure arguments: NGX_CONFIGURE NGX_LINEFEED);}if (!ngx_test_config) {return 0;}}/* TODO */ ngx_max_sockets -1;//初始化并更新时间ngx_time_init();#if (NGX_PCRE)ngx_regex_init(); #endif//获取nginx的进程号ngx_pid ngx_getpid();//初始化日志log ngx_log_init(ngx_prefix);if (log NULL) {return 1;}/* STUB */ #if (NGX_OPENSSL)ngx_ssl_init(log); #endif/** init_cycle-log is required for signal handlers and* ngx_process_options()*//* 初始化ngx_cycle* #define ngx_memzero(buf, n)(void) memset(buf, 0, n)*/ngx_memzero(init_cycle, sizeof(ngx_cycle_t));init_cycle.log log;ngx_cycle init_cycle;//分配内存池init_cycle.pool ngx_create_pool(1024, log);if (init_cycle.pool NULL) {return 1;}//将命令行参数保存到init_cycle结构体中if (ngx_save_argv(init_cycle, argc, argv) ! NGX_OK) {return 1;}//用运行nginx时可能携带的目录参数来初始化cycleif (ngx_process_options(init_cycle) ! NGX_OK) {return 1;}//提取当前操作系统的一些信息if (ngx_os_init(log) ! NGX_OK) {return 1;}/** ngx_crc32_table_init() requires ngx_cacheline_size set in ngx_os_init()*///初始化一个循环冗余校验的表//后续的循环冗余校验可以直接查表if (ngx_crc32_table_init() ! NGX_OK) {return 1;}//这个函数是为了执行不重启服务升级nginx做准备//通过环境变量NGINX_VAR将老的nginx进程需要监听的端口传给新的nginx进程,这样就可以读取平滑升级的信息了if (ngx_add_inherited_sockets(init_cycle) ! NGX_OK) {return 1;}//对所有模块进行编号//ngx_modules数组在编译时已经生成了ngx_max_module 0;for (i 0; ngx_modules[i]; i) {ngx_modules[i]-index ngx_max_module;}//大部分的初始化工作都在ngx_init_cycle中进行cycle ngx_init_cycle(init_cycle);if (cycle NULL) {if (ngx_test_config) {ngx_log_stderr(0, configuration file %s test failed,init_cycle.conf_file.data);}return 1;}if (ngx_test_config) {if (!ngx_quiet_mode) {ngx_log_stderr(0, configuration file %s test is successful,cycle-conf_file.data);}return 0;}if (ngx_signal) {return ngx_signal_process(cycle, ngx_signal);}ngx_os_status(cycle-log);ngx_cycle cycle;//获取存储ngx_core_module模块感兴趣的配置项的结构体指针ccf (ngx_core_conf_t *) ngx_get_conf(cycle-conf_ctx, ngx_core_module);//#define NGX_PROCESS_SINGLE 0 //#define NGX_PROCESS_MASTER 1 //#define NGX_PROCESS_SIGNALLER 2 //#define NGX_PROCESS_WORKER 3 //#define NGX_PROCESS_HELPER 4 //ccf-master若设置为on(1),并且ngx_process设置为单进程模式时//此时由master进程设置的模式为准,为NGX_PROCESS_MASTERif (ccf-master ngx_process NGX_PROCESS_SINGLE) {ngx_process NGX_PROCESS_MASTER;}#if !(NGX_WIN32)//完成对信号的注册等工作if (ngx_init_signals(cycle-log) ! NGX_OK) {return 1;}//若没有继承sockets,并且设置了守护进程标识位//则创建守护进程if (!ngx_inherited ccf-daemon) {if (ngx_daemon(cycle-log) ! NGX_OK) {return 1;}ngx_daemonized 1;}if (ngx_inherited) {ngx_daemonized 1;}#endif//创建进程记录文件if (ngx_create_pidfile(ccf-pid, cycle-log) ! NGX_OK) {return 1;}if (cycle-log-file-fd ! ngx_stderr) {if (ngx_set_stderr(cycle-log-file-fd) NGX_FILE_ERROR) {ngx_log_error(NGX_LOG_EMERG, cycle-log, ngx_errno,ngx_set_stderr_n failed);return 1;}}if (log-file-fd ! ngx_stderr) {if (ngx_close_file(log-file-fd) NGX_FILE_ERROR) {ngx_log_error(NGX_LOG_ALERT, cycle-log, ngx_errno,ngx_close_file_n built-in log failed);}}ngx_use_stderr 0;//进入进程主循环//单进程方式运行nginxif (ngx_process NGX_PROCESS_SINGLE) {ngx_single_process_cycle(cycle);} else {//以master-worker方式运行nginxngx_master_process_cycle(cycle);}return 0; } main函数的代码逻辑大概就是这样,下面介绍一下ngx_cycle_t结构体,然后分析下ngx_init_cycle函数。
http://www.lebaoying.cn/news/46242.html

相关文章:

  • 商丘网站网站建设西凤酒网站建设
  • 手机网站开发方案私人网站建设成本
  • 运城做网站用eclipse做网站模板
  • 征婚网站咋做网站集约化建设 技术
  • 质感设计网站建立个人网站怎么赚钱
  • 怎么套模板做网站nginx反代wordpress伪静态
  • wordpress全站网易云音乐播放四川住房与城乡建设部网站
  • 常州企业建站系统模板开发公司竣工员工奖励计划
  • 深圳市专业的做网站兰溪网站
  • 网站备案域名更改公司做淘宝网站目的是什么
  • dw怎么做网站后台长沙网站推广 下拉通推广
  • 行业门户网站营销案例网站交换链接的常见形式
  • 菜鸟如何建网站西安建筑工程有限公司
  • 成品网站1688入门网行业协会网站建设方案
  • 宝安多屏网站建设公司好吗云主机 免费
  • 云主机建网站教程网站建设及托管合同
  • 红酒论坛网站建设施工企业的主要负责人是本单位的
  • 网页设计怎么分析网站啊学校网站建设宗旨
  • 租车网站建设系统的设计金阊企业建设网站公司
  • 阿里巴巴网站建设销售山东官方网站栖霞市观里镇少城镇建设规划
  • 建设工程 法律 网站做网站最烂公司
  • 外贸soho自己建站柳州专业网站建设加盟
  • 台州市建站公司网站建设属营改增范围吗
  • 公司网站如何被收录云南网官网
  • 直播网站开发费用就业前景好的专业排名
  • 网站服务器有问题怎么办啊二次元wordpress主题
  • python数据分析做网站在本地怎么做网站
  • 移动网站建设指南用h5做网站是什么意思
  • seo网站优化工具大全陕西网站建设公司找哪家好
  • 网站备案和前置审批wordpress多级分类文章