soft

soft

nginx void(*exit_master)(ngx_cycle_t *cycle) free_resource

static void free_resource(ngx_cycle_t* cycle) {
	ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "[%s %d]%Z", __FUNCTION__, __LINE__);
	//return;
	/*
	1 get ngx_http_core_main_conf_t:  ((ngx_http_conf_ctx_t *) cycle->conf_ctx[ngx_http_module.index])->main_conf[ngx_http_core_module.ctx_index]
	2 get ngx_http_core_module servers_list(ngx_array_t): ngx_http_core_main_conf_t*  ->servers
	3 ergodic servers
	4 ngx_http_core_srv_conf_t*= *(ngx_http_core_srv_conf_t**) servers->item
	5 get ngx_http_core_srv_conf_t context:s_ctx=ngx_http_core_srv_conf_t->ctx
	6 get user_my_module_srv_conf :v_srv_conf=s_ctx->srv_conf[ngx_http_waf_module.ctx_index]
	7 get user_my_module_srv_conf-shh_zone:v_srv_conf->shm_zone
	8 see user_my_module_srv_conf-shh_zone-data is equal v_srv_conf :v_srv_conf->shm_zone->data===v_srv_conf
	*/
	ngx_http_waf_main_conf_t* main_conf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_waf_module);
	if (NULL != main_conf) {
		if (NGX_CONF_UNSET !=main_conf->mmdb_status)
		{
			//ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "[%V][%s %d]%Z", &main_conf->waf_data_dir_path, __FUNCTION__, __LINE__);
			MMDB_s mmdb = main_conf->mmdb_infos;
			MMDB_close(&mmdb);
		}	
	}
	ngx_http_core_main_conf_t* cmain_conf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
	ngx_array_t servers_array = cmain_conf->servers;
	void* p = (void*)servers_array.elts;
	//ngx_log_error(ngx_log_alert,cycle->log, 0,"nelts==[%d]",(int)servers_array.nelts);
	ngx_uint_t i = 0;
	for (i = 0; i < servers_array.nelts; i++)
	{
		char* core_srv_conf_p = (char*)p + i * servers_array.size;
		if (core_srv_conf_p) {
			ngx_http_core_srv_conf_t* core_srv_conf = *(ngx_http_core_srv_conf_t**)core_srv_conf_p;
			//ngx_log_error(ngx_log_alert,cycle->log, 0,"core_srv_conf==[%p],file_name=[%s],size={%xd}",core_srv_conf,core_srv_conf->file_name,(int)servers_array.size);
			ngx_http_conf_ctx_t* s_ctx = core_srv_conf->ctx;
			if (s_ctx) {
				void* v_srv_conf = s_ctx->srv_conf[ngx_http_waf_module.ctx_index];
				//ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "[FREE SERVER RESOURCES][%s %d]%Z", __FUNCTION__, __LINE__);
				ngx_http_waf_srv_conf_t* srv_conf = (ngx_http_waf_srv_conf_t*)v_srv_conf;
				ngx_close_file(srv_conf->log_fd);
				if (NULL!= srv_conf->hyperscan_scratch && NGX_CONF_UNSET_PTR!= srv_conf->hyperscan_scratch)
				{
					 //free hyperscan_scratch
					free_static_scratch(srv_conf);
				}
				//ngx_log_error(ngx_log_alert,cycle->log, 0,"srv_conf->ip_req_info_array==[%p],shm_zone->[%p],",srv_conf->ip_req_info_array,srv_conf->shm_zone);
				//if (srv_conf->shm_zone) {
				//	ngx_http_waf_srv_conf_t* save_o_srv_conf = srv_conf->shm_zone->data;
				//	ngx_log_error(ngx_log_alert, cycle->log, 0, "shm_zone-ip_req_info_array[%p],srv_conf->ip_req_info_array[%p]", save_o_srv_conf->ip_req_info_array, srv_conf->ip_req_info_array);
				//	//ngx_log_error(ngx_log_alert,cycle->log, 0,"srv_conf->ip_req_info_array==[%p],shm_zone->[%p],srv_conf->shm_zone->data->[%p]",srv_conf->ip_req_info_array,srv_conf->shm_zone,srv_conf->shm_zone->data);
				//}
			}
		}

	}
	return;
}


发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

联系我 331434376    15629529961