diff options
author | Dmitry Stogov <dmitry@zend.com> | 2015-09-18 10:36:09 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2015-09-18 10:36:09 +0300 |
commit | 6a3580fd567dfbb7fa9bf38b0a4bbc1bf6126cb1 (patch) | |
tree | c9375e97a4175de4ac29c4314a39d9af5e20c429 /ext/mysqlnd | |
parent | cc875d1a25470c72a1bb8ce88388ce7f9e5ce737 (diff) | |
download | php-git-6a3580fd567dfbb7fa9bf38b0a4bbc1bf6126cb1.tar.gz |
Use Zend MM to keep statistic of non-persistent connections (calloc/free->pecalloc/pefree)
Diffstat (limited to 'ext/mysqlnd')
-rw-r--r-- | ext/mysqlnd/mysqlnd.c | 4 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_driver.c | 4 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_plugin.c | 4 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_statistics.c | 16 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_statistics.h | 4 |
5 files changed, 16 insertions, 16 deletions
diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index d60a83c67d..1a1882cdd7 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -199,7 +199,7 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_conn_data, dtor)(MYSQLND_CONN_DATA * conn) } if (conn->stats) { - mysqlnd_stats_end(conn->stats); + mysqlnd_stats_end(conn->stats, conn->persistent); } mnd_pefree(conn, conn->persistent); @@ -2971,7 +2971,7 @@ static enum_func_status 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); diff --git a/ext/mysqlnd/mysqlnd_driver.c b/ext/mysqlnd/mysqlnd_driver.c index 90da451ae4..628e02659d 100644 --- a/ext/mysqlnd/mysqlnd_driver.c +++ b/ext/mysqlnd/mysqlnd_driver.c @@ -57,7 +57,7 @@ PHPAPI void mysqlnd_library_end(void) { 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(); @@ -75,7 +75,7 @@ PHPAPI void mysqlnd_library_init(void) 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; diff --git a/ext/mysqlnd/mysqlnd_plugin.c b/ext/mysqlnd/mysqlnd_plugin.c index 094bd554ae..c392429807 100644 --- a/ext/mysqlnd/mysqlnd_plugin.c +++ b/ext/mysqlnd/mysqlnd_plugin.c @@ -71,7 +71,7 @@ enum_func_status mysqlnd_example_plugin_end(void * p) { 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); } @@ -82,7 +82,7 @@ enum_func_status mysqlnd_example_plugin_end(void * p) 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); } diff --git a/ext/mysqlnd/mysqlnd_statistics.c b/ext/mysqlnd/mysqlnd_statistics.c index f550948035..094ea11f3d 100644 --- a/ext/mysqlnd/mysqlnd_statistics.c +++ b/ext/mysqlnd/mysqlnd_statistics.c @@ -230,14 +230,14 @@ _mysqlnd_get_client_stats(zval *return_value ZEND_FILE_LINE_DC) /* {{{ 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 @@ -249,15 +249,15 @@ mysqlnd_stats_init(MYSQLND_STATS ** stats, size_t statistic_count) /* {{{ 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); } /* }}} */ diff --git a/ext/mysqlnd/mysqlnd_statistics.h b/ext/mysqlnd/mysqlnd_statistics.h index ea2611c19c..19aedf37a2 100644 --- a/ext/mysqlnd/mysqlnd_statistics.h +++ b/ext/mysqlnd/mysqlnd_statistics.h @@ -159,8 +159,8 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[]; 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); |