>  기사  >  백엔드 개발  >  Nginx 메인 ngx_init_cycle()에 대한 예비 탐색(1부)

Nginx 메인 ngx_init_cycle()에 대한 예비 탐색(1부)

WBOY
WBOY원래의
2016-08-08 09:28:471214검색

Nginx 메인의 ngx_init_cycle()에 대한 예비 연구(1부)

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()
				        -->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 <= &#39;Z&#39;) ? (c | 0x20) : 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 <stdio.h>
	#include <stdlib.h>
	#include <time.h>


	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;
	}

프로그램 출력 결과 :
<span style="white-space:pre">	</span>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 <stdio.h>
	#include <stdlib.h>


	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 ngx_init_cycle()(1부)의 주요 탐색을 소개합니다. PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되기를 바랍니다.

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
이전 기사:Laravel 연구 노트다음 기사:Laravel 연구 노트