/** * free the global scope * * closes all open connections, cleans up all plugins * * @param chas global context */ void chassis_free(chassis *chas) { guint i; #ifdef HAVE_EVENT_BASE_FREE const char *version; #endif if (!chas) return; /* call the destructor for all plugins */ for (i = 0; i < chas->modules->len; i++) { chassis_plugin *p = chas->modules->pdata[i]; g_assert(p->destroy); p->destroy(p->config); } chassis_shutdown_hooks_call(chas->shutdown_hooks); /* cleanup the global 3rd party stuff before we unload the modules */ for (i = 0; i < chas->modules->len; i++) { chassis_plugin *p = chas->modules->pdata[i]; chassis_plugin_free(p); } g_ptr_array_free(chas->modules, TRUE); if (chas->base_dir) g_free(chas->base_dir); if (chas->log_path) g_free(chas->log_path); if (chas->user) g_free(chas->user); if (chas->stats) chassis_stats_free(chas->stats); chassis_timestamps_global_free(NULL); GPtrArray *threads = chas->threads; if (threads) { for (i = 0; i < threads->len; ++i) { chassis_event_thread_free(threads->pdata[i]); } g_ptr_array_free(threads, TRUE); } if (chas->instance_name) g_free(chas->instance_name); #ifdef HAVE_EVENT_BASE_FREE /* only recent versions have this call */ version = event_get_version(); /* libevent < 1.3e doesn't cleanup its own fds from the event-queue in signal_init() * calling event_base_free() would cause a assert() on shutdown */ if (version && (strcmp(version, "1.3e") >= 0)) { if (chas->event_base) event_base_free(chas->event_base); } #endif g_free(chas->event_hdr_version); chassis_shutdown_hooks_free(chas->shutdown_hooks); lua_scope_free(chas->sc); network_backends_free(chas->backends); if (chas->proxy_filter != NULL) { sql_filter_free(chas->proxy_filter); } if (chas->proxy_reserved != NULL) { sql_reserved_query_free(chas->proxy_reserved); } g_free(chas); }
/** * free the global scope * * closes all open connections, cleans up all plugins * * @param chas global context */ void chassis_free(chassis *chas) { guint i; #ifdef HAVE_EVENT_BASE_FREE const char *version; #endif if (!chas) return; /* init the shutdown, without freeing share structures */ if (chas->priv_shutdown) chas->priv_shutdown(chas, chas->priv); /* call the destructor for all plugins */ for (i = 0; i < chas->modules->len; i++) { chassis_plugin *p = chas->modules->pdata[i]; g_assert(p->destroy); p->destroy(p->config); } chassis_shutdown_hooks_call(chas->shutdown_hooks); /* cleanup the global 3rd party stuff before we unload the modules */ for (i = 0; i < chas->modules->len; i++) { chassis_plugin *p = chas->modules->pdata[i]; chassis_plugin_free(p); } g_ptr_array_free(chas->modules, TRUE); /* free the pointers _AFTER_ the modules are shutdown */ if (chas->priv_free) chas->priv_free(chas, chas->priv); if (chas->base_dir) g_free(chas->base_dir); if (chas->user) g_free(chas->user); if (chas->stats) chassis_stats_free(chas->stats); chassis_timestamps_global_free(NULL); if (chas->threads) chassis_event_threads_free(chas->threads); #ifdef HAVE_EVENT_BASE_FREE /* only recent versions have this call */ version = event_get_version(); /* libevent < 1.3e doesn't cleanup its own fds from the event-queue in signal_init() * calling event_base_free() would cause a assert() on shutdown */ if (version && (strcmp(version, "1.3e") >= 0)) { if (chas->event_base) event_base_free(chas->event_base); } #endif g_free(chas->event_hdr_version); chassis_shutdown_hooks_free(chas->shutdown_hooks); //add by vinchen/CFR if (chas->set_mutex) { g_mutex_free(chas->set_mutex); } if (chas->user_ip_set){ g_set_destroy(chas->user_ip_set); } if (chas->base_dir_org) g_free(chas->base_dir_org); if (chas->lua_cpath_org) g_free(chas->lua_cpath_org); if (chas->lua_path_org) g_free(chas->lua_path_org); if (chas->log_file_name_org) g_free(chas->log_file_name_org); if (chas->plugin_dir_org) g_free(chas->plugin_dir_org); if (chas->pid_file_org) g_free(chas->pid_file_org); if (chas->default_file) g_free(chas->default_file); if(chas->ignore_user) g_strfreev(chas->ignore_user); if (chas->query_mutex) g_mutex_free(chas->query_mutex); g_free(chas); }