}
if (conn->stats) {
- mysqlnd_stats_end(conn->stats);
+ mysqlnd_stats_end(conn->stats, conn->persistent);
}
mnd_pefree(conn, conn->persistent);
MYSQLND_METHOD(mysqlnd_conn_data, init)(MYSQLND_CONN_DATA * conn)
{
DBG_ENTER("mysqlnd_conn_data::init");
- mysqlnd_stats_init(&conn->stats, STAT_LAST);
+ mysqlnd_stats_init(&conn->stats, STAT_LAST, conn->persistent);
SET_ERROR_AFF_ROWS(conn);
conn->net = mysqlnd_net_init(conn->persistent, conn->stats, conn->error_info);
{
if (mysqlnd_library_initted == TRUE) {
mysqlnd_plugin_subsystem_end();
- mysqlnd_stats_end(mysqlnd_global_stats);
+ mysqlnd_stats_end(mysqlnd_global_stats, 1);
mysqlnd_global_stats = NULL;
mysqlnd_library_initted = FALSE;
mysqlnd_reverse_api_end();
mysqlnd_conn_data_set_methods(&MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_conn_data));
_mysqlnd_init_ps_subsystem();
/* Should be calloc, as mnd_calloc will reference LOCK_access*/
- mysqlnd_stats_init(&mysqlnd_global_stats, STAT_LAST);
+ mysqlnd_stats_init(&mysqlnd_global_stats, STAT_LAST, 1);
mysqlnd_plugin_subsystem_init();
{
mysqlnd_plugin_core.plugin_header.plugin_stats.values = mysqlnd_global_stats;
{
struct st_mysqlnd_typeii_plugin_example * plugin = (struct st_mysqlnd_typeii_plugin_example *) p;
DBG_ENTER("mysqlnd_example_plugin_end");
- mysqlnd_stats_end(plugin->plugin_header.plugin_stats.values);
+ mysqlnd_stats_end(plugin->plugin_header.plugin_stats.values, 1);
plugin->plugin_header.plugin_stats.values = NULL;
DBG_RETURN(PASS);
}
void
mysqlnd_example_plugin_register(void)
{
- mysqlnd_stats_init(&mysqlnd_plugin_example_stats, EXAMPLE_STAT_LAST);
+ mysqlnd_stats_init(&mysqlnd_plugin_example_stats, EXAMPLE_STAT_LAST, 1);
mysqlnd_example_plugin.plugin_header.plugin_stats.values = mysqlnd_plugin_example_stats;
mysqlnd_plugin_register_ex((struct st_mysqlnd_plugin_header *) &mysqlnd_example_plugin);
}
/* {{{ mysqlnd_stats_init */
PHPAPI void
-mysqlnd_stats_init(MYSQLND_STATS ** stats, size_t statistic_count)
+mysqlnd_stats_init(MYSQLND_STATS ** stats, size_t statistic_count, int persistent)
{
- *stats = calloc(1, sizeof(MYSQLND_STATS));
+ *stats = pecalloc(1, sizeof(MYSQLND_STATS), persistent);
if (*stats == NULL) {
return;
}
- (*stats)->values = calloc(statistic_count, sizeof(uint64_t));
- (*stats)->triggers = calloc(statistic_count, sizeof(mysqlnd_stat_trigger));
+ (*stats)->values = pecalloc(statistic_count, sizeof(uint64_t), persistent);
+ (*stats)->triggers = pecalloc(statistic_count, sizeof(mysqlnd_stat_trigger), persistent);
(*stats)->in_trigger = FALSE;
(*stats)->count = statistic_count;
#ifdef ZTS
/* {{{ mysqlnd_stats_end */
PHPAPI void
-mysqlnd_stats_end(MYSQLND_STATS * stats)
+mysqlnd_stats_end(MYSQLND_STATS * stats, int persistent)
{
#ifdef ZTS
tsrm_mutex_free(stats->LOCK_access);
#endif
- free(stats->triggers);
- free(stats->values);
+ pefree(stats->triggers, persistent);
+ pefree(stats->values, persistent);
/* mnd_free will reference LOCK_access and crash...*/
- free(stats);
+ pefree(stats, persistent);
}
/* }}} */
PHPAPI void mysqlnd_fill_stats_hash(const MYSQLND_STATS * const stats, const MYSQLND_STRING * names, zval *return_value ZEND_FILE_LINE_DC);
-PHPAPI void mysqlnd_stats_init(MYSQLND_STATS ** stats, size_t statistic_count);
-PHPAPI void mysqlnd_stats_end(MYSQLND_STATS * stats);
+PHPAPI void mysqlnd_stats_init(MYSQLND_STATS ** stats, size_t statistic_count, int persistent);
+PHPAPI void mysqlnd_stats_end(MYSQLND_STATS * stats, int persistent);
PHPAPI mysqlnd_stat_trigger mysqlnd_stats_set_trigger(MYSQLND_STATS * const stats, enum_mysqlnd_collected_stats stat, mysqlnd_stat_trigger trigger);
PHPAPI mysqlnd_stat_trigger mysqlnd_stats_reset_triggers(MYSQLND_STATS * const stats);