昨晚用graphviz画了一个nginx的函数调用关系图. 可以帮助理解nginx的代码. 分享给大家.
nginx代码版本:
1.0.2
总共T除了如下函数的调用:
ngx_array_push|ngx_palloc|ngx_strlow|ngx_pnalloc|ngx_pcalloc|ngx_sprintf_num|ngx_array_init|ngx_conf_read_token|ngx_hash_strlow|ngx_hash_key|ngx_hash_add_key|ngx_hash_key_lc|ngx_http_core_type|ngx_http_merge_locations|ngx_cpystrn|ngx_alloc|ngx_strncasecmp|ngx_array_create|ngx_http_merge_servers|ngx_vslprintf|ngx_array_push_n|ngx_hash_init|ngx_sprintf|ngx_conf_handler|ngx_http_add_variable|ngx_conf_merge_path_value|ngx_conf_test_full_name|ngx_conf_full_name|ngx_strcasecmp|ngx_http_upstream_hide_headers_hash|ngx_http_get_indexed_variable|ngx_http_merge_types|ngx_http_log_copy_short|ngx_conf_parse|ngx_memalign|ngx_atoi|ngx_time_update|ngx_strstrn|ngx_list_push|ngx_http_script_variables_count
由于原始数据的函数太多, 会导致生成的图太大, 所以这里剔除了一些不重要的函数的调用.
该图完整的记录了单进程模式的nginx从启动, 到收到 http://127.0.0.1 请求并处理, 再到退出的完整流程.