• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

Nginx之main初探ngx_init_cycle()(上)

php 搞代码 3年前 (2022-01-23) 22次浏览 已收录 0个评论

Nginx之main初探ngx_init_cycle()(上)

由于ngx_init_cycle()函数非常庞大,这里只给出前400+行的函数调用关系,后400+将在后面的文章中给出。

-->ngx_init_cycle(&init_cycle)	    -->ngx_timezone_update()		    -->time()			-->localtime()注1:		-->ngx_timeofday()		-->ngx_time_update()		    -->ngx_gettimeofday() -- gettimeofday()			-->ngx_gmtime()			-->ngx_localtime()			-->ngx_memory_barrier()		-->ngx_increase_pipe_generation()		-->ngx_create_pool()			-->ngx_memalign() --  ngx_alloc(size, log)		-->ngx_pcalloc()		    -->ngx_palloc()			    -->ngx_align_ptr()注2:			    -->ngx_palloc_block()			        -->ngx_memalign()				    -->ngx_align_ptr()			    -->ngx_palloc_large()			        -->ngx_alloc()				  ~来1源gaodai#ma#com搞*代#码1网搞代gaodaima码      -->malloc()				    -->ngx_palloc()				-->ngx_memzero()			    -->memset()		-->ngx_list_init()		    -->ngx_palloc()		-->ngx_queue_init()		-->ngx_strlen() -- strlen()		-->ngx_pnalloc()		    -->ngx_palloc_block()			-->ngx_palloc_large()		-->ngx_strlow()		    -->ngx_tolower() -- ((c >= 'A' && c ngx_array_create()		    -->ngx_palloc()			-->ngx_array_init()			    -->ngx_palloc()		-->ngx_conf_param()		    -->ngx_memzero()			-->ngx_conf_parse()		-->ngx_conf_parse()		    -->ngx_open_file()  -- open()			-->ngx_fd_info()  -- fstat()			-->ngx_alloc()			-->ngx_conf_read_token()			    -->ngx_file_size()				-->ngx_memmove()  --  memmove()				-->ngx_read_file()   -- read()				-->ngx_write_console() -- ngx_write_fd()				    --> write()				-->ngx_array_push()			-->ngx_conf_handler()		-->ngx_show_dso_directives()		    -->ngx_get_conf()		-->ngx_is_dynamic_module()		    -->ngx_get_conf()		-->ngx_test_lockfile()		    -->ngx_open_file()			-->ngx_close_file()			-->ngx_delete_file()		-->ngx_create_paths()		    -->ngx_create_dir() -- mkdir()			-->ngx_file_info()		-->ngx_log_open_default()		    -->ngx_conf_open_file()

下面是陌生函数的用法和小知识点:

注1:time()与localtime()函数不是Nginx自己实现的,是库函数。其用法如下

/**	 * filename:    test_localtime.c	 * description: used to see the usage of function localtime()	 * date:        2015-03-06	 * author:      HowardKing	 * version:     1.0	 */	#include 	#include 	#include 	int main(void)	{			time_t timer; // time_t is long int			struct tm *tblock;			time(NULL);			tblock = localtime(&timer);			printf("Local time is: %s", asctime(tblock));			return 0;	}

程序输出结果:

	Local time is: Fri Jul 31 05:00:00 4461676


注2:C语言中long类型是与机器字长相对应的,而int型来说一般都是4字节。

/**	 * filename:    test_unsigned_long.c	 * description: find out the size of type long	 * date:        20150306	 * author:      HowardKing	 * version:     v1.0	 */	#include 	#include 	int main(void)	{			int ii = 100;			unsigned long ll = 100;			printf("%d\n", sizeof(ii));			printf("%d\n", sizeof(ll));			return 0;	}

程序输出结果:

	4	8

以上就介绍了Nginx之main初探ngx_init_cycle()(上),包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Nginx之main初探ngx_init_cycle()(上)

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址