diff options
Diffstat (limited to 'ext/mysqlnd/php_mysqlnd.c')
-rw-r--r-- | ext/mysqlnd/php_mysqlnd.c | 106 |
1 files changed, 52 insertions, 54 deletions
diff --git a/ext/mysqlnd/php_mysqlnd.c b/ext/mysqlnd/php_mysqlnd.c index 337f06a198..5c8a7d81e9 100644 --- a/ext/mysqlnd/php_mysqlnd.c +++ b/ext/mysqlnd/php_mysqlnd.c @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ - | PHP Version 5 | + | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 2006-2016 The PHP Group | +----------------------------------------------------------------------+ @@ -12,13 +12,12 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Andrey Hristov <andrey@mysql.com> | - | Ulf Wendel <uwendel@mysql.com> | - | Georg Richter <georg@mysql.com> | + | Authors: Andrey Hristov <andrey@php.net> | + | Ulf Wendel <uw@php.net> | + | Georg Richter <georg@php.net> | +----------------------------------------------------------------------+ */ -/* $Id$ */ #include "php.h" #include "php_ini.h" #include "mysqlnd.h" @@ -27,7 +26,7 @@ #include "mysqlnd_statistics.h" #include "mysqlnd_reverse_api.h" #include "ext/standard/info.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" /* {{{ mysqlnd_functions[] * @@ -43,37 +42,28 @@ static zend_function_entry mysqlnd_functions[] = { PHPAPI void mysqlnd_minfo_print_hash(zval *values) { - zval **values_entry; - HashPosition pos_values; + zval *values_entry; + zend_string *string_key; - zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(values), &pos_values); - while (zend_hash_get_current_data_ex(Z_ARRVAL_P(values), (void **)&values_entry, &pos_values) == SUCCESS) { - char *string_key; - uint string_key_len; - ulong num_key; - - zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &string_key, &string_key_len, &num_key, 0, &pos_values); - - convert_to_string(*values_entry); - php_info_print_table_row(2, string_key, Z_STRVAL_PP(values_entry)); - - zend_hash_move_forward_ex(Z_ARRVAL_P(values), &pos_values); - } + ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(values), string_key, values_entry) { + convert_to_string(values_entry); + php_info_print_table_row(2, ZSTR_VAL(string_key), Z_STRVAL_P(values_entry)); + } ZEND_HASH_FOREACH_END(); } /* }}} */ /* {{{ mysqlnd_minfo_dump_plugin_stats */ static int -mysqlnd_minfo_dump_plugin_stats(void *pDest, void * argument TSRMLS_DC) +mysqlnd_minfo_dump_plugin_stats(zval *el, void * argument) { - struct st_mysqlnd_plugin_header * plugin_header = *(struct st_mysqlnd_plugin_header **) pDest; + struct st_mysqlnd_plugin_header * plugin_header = (struct st_mysqlnd_plugin_header *)Z_PTR_P(el); if (plugin_header->plugin_stats.values) { char buf[64]; zval values; snprintf(buf, sizeof(buf), "%s statistics", plugin_header->plugin_name); - mysqlnd_fill_stats_hash(plugin_header->plugin_stats.values, plugin_header->plugin_stats.names, &values TSRMLS_CC ZEND_FILE_LINE_CC); + mysqlnd_fill_stats_hash(plugin_header->plugin_stats.values, plugin_header->plugin_stats.names, &values ZEND_FILE_LINE_CC); php_info_print_table_start(); php_info_print_table_header(2, buf, ""); @@ -87,13 +77,13 @@ mysqlnd_minfo_dump_plugin_stats(void *pDest, void * argument TSRMLS_DC) /* {{{ mysqlnd_minfo_dump_loaded_plugins */ -static int -mysqlnd_minfo_dump_loaded_plugins(void *pDest, void * buf TSRMLS_DC) +static int +mysqlnd_minfo_dump_loaded_plugins(zval *el, void * buf) { smart_str * buffer = (smart_str *) buf; - struct st_mysqlnd_plugin_header * plugin_header = *(struct st_mysqlnd_plugin_header **) pDest; + struct st_mysqlnd_plugin_header * plugin_header = (struct st_mysqlnd_plugin_header *)Z_PTR_P(el); if (plugin_header->plugin_name) { - if (buffer->len) { + if (buffer->s) { smart_str_appendc(buffer, ','); } smart_str_appends(buffer, plugin_header->plugin_name); @@ -102,23 +92,20 @@ mysqlnd_minfo_dump_loaded_plugins(void *pDest, void * buf TSRMLS_DC) } /* }}} */ + /* {{{ mysqlnd_minfo_dump_api_plugins */ static void -mysqlnd_minfo_dump_api_plugins(smart_str * buffer TSRMLS_DC) +mysqlnd_minfo_dump_api_plugins(smart_str * buffer) { - HashTable *ht = mysqlnd_reverse_api_get_api_list(TSRMLS_C); - HashPosition pos; - MYSQLND_REVERSE_API **ext; - - for (zend_hash_internal_pointer_reset_ex(ht, &pos); - zend_hash_get_current_data_ex(ht, (void **) &ext, &pos) == SUCCESS; - zend_hash_move_forward_ex(ht, &pos) - ) { - if (buffer->len) { + HashTable *ht = mysqlnd_reverse_api_get_api_list(); + MYSQLND_REVERSE_API *ext; + + ZEND_HASH_FOREACH_PTR(ht, ext) { + if (buffer->s) { smart_str_appendc(buffer, ','); } - smart_str_appends(buffer, (*ext)->module->name); - } + smart_str_appends(buffer, ext->module->name); + } ZEND_HASH_FOREACH_END(); } /* }}} */ @@ -150,11 +137,11 @@ PHP_MINFO_FUNCTION(mysqlnd) #else "not supported"); #endif - snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_cmd_buffer_size)); + snprintf(buf, sizeof(buf), ZEND_LONG_FMT, MYSQLND_G(net_cmd_buffer_size)); php_info_print_table_row(2, "Command buffer size", buf); - snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_read_buffer_size)); + snprintf(buf, sizeof(buf), ZEND_LONG_FMT, MYSQLND_G(net_read_buffer_size)); php_info_print_table_row(2, "Read buffer size", buf); - snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_read_timeout)); + snprintf(buf, sizeof(buf), ZEND_LONG_FMT, MYSQLND_G(net_read_timeout)); php_info_print_table_row(2, "Read timeout", buf); php_info_print_table_row(2, "Collecting statistics", MYSQLND_G(collect_statistics)? "Yes":"No"); php_info_print_table_row(2, "Collecting memory statistics", MYSQLND_G(collect_memory_statistics)? "Yes":"No"); @@ -163,15 +150,15 @@ PHP_MINFO_FUNCTION(mysqlnd) /* loaded plugins */ { - smart_str tmp_str = {0, 0, 0}; + smart_str tmp_str = {0}; mysqlnd_plugin_apply_with_argument(mysqlnd_minfo_dump_loaded_plugins, &tmp_str); smart_str_0(&tmp_str); - php_info_print_table_row(2, "Loaded plugins", tmp_str.c); + php_info_print_table_row(2, "Loaded plugins", tmp_str.s? ZSTR_VAL(tmp_str.s) : ""); smart_str_free(&tmp_str); - mysqlnd_minfo_dump_api_plugins(&tmp_str TSRMLS_CC); + mysqlnd_minfo_dump_api_plugins(&tmp_str); smart_str_0(&tmp_str); - php_info_print_table_row(2, "API Extensions", tmp_str.c); + php_info_print_table_row(2, "API Extensions", tmp_str.s? ZSTR_VAL(tmp_str.s) : ""); smart_str_free(&tmp_str); } @@ -191,6 +178,9 @@ PHPAPI ZEND_DECLARE_MODULE_GLOBALS(mysqlnd) */ static PHP_GINIT_FUNCTION(mysqlnd) { +#if defined(COMPILE_DL_MYSQLND) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE(); +#endif mysqlnd_globals->collect_statistics = TRUE; mysqlnd_globals->collect_memory_statistics = FALSE; mysqlnd_globals->debug = NULL; /* The actual string */ @@ -214,9 +204,13 @@ static PHP_GINIT_FUNCTION(mysqlnd) /* }}} */ +/* {{{ PHP_INI_MH + */ static PHP_INI_MH(OnUpdateNetCmdBufferSize) { - long long_value = atol(new_value); + zend_long long_value; + + ZEND_ATOL(long_value, ZSTR_VAL(new_value)); if (long_value < MYSQLND_NET_CMD_BUFFER_MIN_SIZE) { return FAILURE; } @@ -224,6 +218,8 @@ static PHP_INI_MH(OnUpdateNetCmdBufferSize) return SUCCESS; } +/* }}} */ + /* {{{ PHP_INI_BEGIN */ @@ -258,7 +254,7 @@ static PHP_MINIT_FUNCTION(mysqlnd) { REGISTER_INI_ENTRIES(); - mysqlnd_library_init(TSRMLS_C); + mysqlnd_library_init(); return SUCCESS; } /* }}} */ @@ -268,7 +264,7 @@ static PHP_MINIT_FUNCTION(mysqlnd) */ static PHP_MSHUTDOWN_FUNCTION(mysqlnd) { - mysqlnd_library_end(TSRMLS_C); + mysqlnd_library_end(); UNREGISTER_INI_ENTRIES(); return SUCCESS; @@ -285,8 +281,8 @@ static PHP_RINIT_FUNCTION(mysqlnd) struct st_mysqlnd_plugin_trace_log * trace_log_plugin = mysqlnd_plugin_find("debug_trace"); MYSQLND_G(dbg) = NULL; if (trace_log_plugin) { - MYSQLND_DEBUG * dbg = trace_log_plugin->methods.trace_instance_init(mysqlnd_debug_std_no_trace_funcs TSRMLS_CC); - MYSQLND_DEBUG * trace_alloc = trace_log_plugin->methods.trace_instance_init(NULL TSRMLS_CC); + MYSQLND_DEBUG * dbg = trace_log_plugin->methods.trace_instance_init(mysqlnd_debug_std_no_trace_funcs); + MYSQLND_DEBUG * trace_alloc = trace_log_plugin->methods.trace_instance_init(NULL); if (!dbg || !trace_alloc) { return FAILURE; } @@ -326,7 +322,6 @@ static PHP_RSHUTDOWN_FUNCTION(mysqlnd) #endif - static const zend_module_dep mysqlnd_deps[] = { ZEND_MOD_REQUIRED("standard") ZEND_MOD_END @@ -353,7 +348,7 @@ zend_module_entry mysqlnd_module_entry = { NULL, #endif PHP_MINFO(mysqlnd), - MYSQLND_VERSION, + PHP_MYSQLND_VERSION, PHP_MODULE_GLOBALS(mysqlnd), PHP_GINIT(mysqlnd), NULL, @@ -364,6 +359,9 @@ zend_module_entry mysqlnd_module_entry = { /* {{{ COMPILE_DL_MYSQLND */ #ifdef COMPILE_DL_MYSQLND +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE() +#endif ZEND_GET_MODULE(mysqlnd) #endif /* }}} */ |