From: Andrey Hristov Date: Mon, 28 Jan 2008 22:50:06 +0000 (+0000) Subject: some config.w32 fixes X-Git-Tag: RELEASE_1_3_1~261 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2033c1b7f2c50146c917a5769a6996f0188f5e14;p=php some config.w32 fixes moved mysqlnd's block allocator to a separate file and also now it's part of the connection, no MT problems. --- diff --git a/ext/mysql/config.w32 b/ext/mysql/config.w32 index a36ba1709c..df3f3556cb 100644 --- a/ext/mysql/config.w32 +++ b/ext/mysql/config.w32 @@ -8,13 +8,15 @@ if (PHP_MYSQL != "no") { if (CHECK_LIB("libmysql.lib", "mysql", PHP_MYSQL) && CHECK_HEADER_ADD_INCLUDE("mysql.h", "CFLAGS_MYSQL", PHP_MYSQL + "\\include;" + PHP_PHP_BUILD + "\\include\\mysql;" + PHP_MYSQL)) { + EXTENSION("mysql", "php_mysql.c"); + AC_DEFINE('HAVE_MYSQL', 1, 'Have MySQL library'); } else { WARNING("mysql not enabled; libraries and headers not found"); } } else { AC_DEFINE('HAVE_MYSQLND', 1, 'MySQL native driver support enabled'); ADD_EXTENSION_DEP('mysql', 'mysqlnd', true); + EXTENSION("mysql", "php_mysql.c"); + AC_DEFINE('HAVE_MYSQL', 1, 'Have MySQL library'); } - EXTENSION("mysql", "php_mysql.c"); - AC_DEFINE('HAVE_MYSQL', 1, 'Have MySQL library'); } diff --git a/ext/mysqli/tests/mysqli_get_client_stats.phpt b/ext/mysqli/tests/mysqli_get_client_stats.phpt index 10cad1e727..042f14bd99 100644 --- a/ext/mysqli/tests/mysqli_get_client_stats.phpt +++ b/ext/mysqli/tests/mysqli_get_client_stats.phpt @@ -969,9 +969,9 @@ array(61) { ["mem_efree_count"]=> string(1) "0" ["mem_malloc_count"]=> - string(1) "1" + string(1) "0" ["mem_malloc_ammount"]=> - string(%d) "%d" + string(1) "0" ["mem_calloc_count"]=> string(1) "0" ["mem_calloc_ammount"]=> @@ -1106,9 +1106,9 @@ array(61) { [u"mem_efree_count"]=> unicode(1) "0" [u"mem_malloc_count"]=> - unicode(1) "1" + unicode(1) "0" [u"mem_malloc_ammount"]=> - unicode(%d) "%d" + unicode(1) "0" [u"mem_calloc_count"]=> unicode(1) "0" [u"mem_calloc_ammount"]=> diff --git a/ext/mysqlnd/config.w32 b/ext/mysqlnd/config.w32 index a01f00d226..8935287b5f 100644 --- a/ext/mysqlnd/config.w32 +++ b/ext/mysqlnd/config.w32 @@ -1,15 +1,12 @@ // $Id$ // vim:ft=javascript -ARG_WITH("mysqlnd", "MySQL-nd support", "no"); - -if (PHP_MYSQLND != "no") { -mysqld_source = ""; if (CHECK_LIB("ws2_32.lib", "mysqlnd")) { mysqlnd_source = "mysqlnd.c " + - "mysqlnd_debug.c " + + "mysqlnd_block_alloc.c" + "mysqlnd_charset.c " + + "mysqlnd_debug.c " + "mysqlnd_loaddata.c " + "mysqlnd_palloc.c " + "mysqlnd_ps.c " + @@ -21,4 +18,3 @@ if (CHECK_LIB("ws2_32.lib", "mysqlnd")) { "mysqlnd_wireprotocol.c"; EXTENSION("mysqlnd", mysqlnd_source, false); } -} \ No newline at end of file diff --git a/ext/mysqlnd/config9.m4 b/ext/mysqlnd/config9.m4 index 9d09ba71da..2a5c330595 100644 --- a/ext/mysqlnd/config9.m4 +++ b/ext/mysqlnd/config9.m4 @@ -7,7 +7,8 @@ if test "$PHP_MYSQLND_ENABLED" = "yes"; then mysqlnd_sources="mysqlnd.c mysqlnd_charset.c mysqlnd_wireprotocol.c \ mysqlnd_ps.c mysqlnd_loaddata.c mysqlnd_palloc.c \ mysqlnd_ps_codec.c mysqlnd_statistics.c mysqlnd_qcache.c\ - mysqlnd_result.c mysqlnd_result_meta.c mysqlnd_debug.c" + mysqlnd_result.c mysqlnd_result_meta.c mysqlnd_debug.c\ + mysqlnd_block_alloc.c" PHP_NEW_EXTENSION(mysqlnd, $mysqlnd_sources, no) PHP_ADD_BUILD_DIR([ext/mysqlnd], 1) diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index 6e7441dcea..2408f8fb8b 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -27,6 +27,7 @@ #include "mysqlnd_statistics.h" #include "mysqlnd_charset.h" #include "mysqlnd_debug.h" +#include "mysqlnd_block_alloc.h" #include "php_ini.h" #include "ext/standard/basic_functions.h" #include "ext/standard/php_lcg.h" @@ -66,7 +67,6 @@ const char * mysqlnd_out_of_sync = "Commands out of sync; you can't run this com MYSQLND_STATS *mysqlnd_global_stats = NULL; static zend_bool mysqlnd_library_initted = FALSE; -MYSQLND_MEMORY_POOL mysqlnd_memory_pool; static enum_func_status mysqlnd_send_close(MYSQLND * conn TSRMLS_DC); @@ -127,140 +127,6 @@ void * _mysqlnd_fetch_thread(void *arg) /* }}} */ #endif /* MYSQLND_THREADED */ -/************************************************************************************************/ -/* Let's don't use pool allocation for now */ -/* {{{ mysqlnd_mempool_free_chunk */ -static -void mysqlnd_mempool_free_contents(MYSQLND_MEMORY_POOL * pool TSRMLS_DC) -{ - DBG_ENTER("mysqlnd_mempool_dtor"); - uint i; - for (i = 0; i < pool->free_chunk_list_elements; i++) { - MYSQLND_MEMORY_POOL_CHUNK * chunk = pool->free_chunk_list[i]; - chunk->free_chunk(chunk, FALSE TSRMLS_CC); - } - - DBG_VOID_RETURN; -} -/* }}} */ - -/* Let's don't use pool allocation for now */ -/* {{{ mysqlnd_mempool_free_chunk */ -static -void mysqlnd_mempool_free_chunk(MYSQLND_MEMORY_POOL_CHUNK * chunk, zend_bool cache_it TSRMLS_DC) -{ - DBG_ENTER("mysqlnd_mempool_free_chunk"); - MYSQLND_MEMORY_POOL * pool = chunk->pool; - if (chunk->from_pool) { - /* Try to back-off and guess if this is the last block allocated */ - if (chunk->ptr == (pool->arena + (pool->arena_size - pool->free_size - chunk->size))) { - /* - This was the last allocation. Lucky us, we can free - a bit of memory from the pool. Next time we will return from the same ptr. - */ - pool->free_size += chunk->size; - } - pool->refcount--; - } else { - mnd_free(chunk->ptr); - } - if (cache_it && pool->free_chunk_list_elements < MYSQLND_MEMORY_POOL_CHUNK_LIST_SIZE) { - chunk->ptr = NULL; - pool->free_chunk_list[pool->free_chunk_list_elements++] = chunk; - } else { - /* We did not cache it -> free it */ - mnd_free(chunk); - } - DBG_VOID_RETURN; -} -/* }}} */ - - -/* {{{ mysqlnd_mempool_resize_chunk */ -static void -mysqlnd_mempool_resize_chunk(MYSQLND_MEMORY_POOL_CHUNK * chunk, uint size TSRMLS_DC) -{ - DBG_ENTER("mysqlnd_mempool_resize_chunk"); - if (chunk->from_pool) { - MYSQLND_MEMORY_POOL * pool = chunk->pool; - /* Try to back-off and guess if this is the last block allocated */ - if (chunk->ptr == (pool->arena + (pool->arena_size - pool->free_size - chunk->size))) { - /* - This was the last allocation. Lucky us, we can free - a bit of memory from the pool. Next time we will return from the same ptr. - */ - if ((chunk->size + pool->free_size) < size) { - zend_uchar *new_ptr; - new_ptr = mnd_malloc(size); - memcpy(new_ptr, chunk->ptr, chunk->size); - chunk->ptr = new_ptr; - pool->free_size += chunk->size; - chunk->size = size; - chunk->pool = NULL; /* now we have no pool memory */ - pool->refcount--; - } else { - /* If the chunk is > than asked size then free_memory increases, otherwise decreases*/ - pool->free_size += (chunk->size - size); - } - } else { - /* Not last chunk, if the user asks for less, give it to him */ - if (chunk->size >= size) { - ; /* nop */ - } else { - zend_uchar *new_ptr; - new_ptr = mnd_malloc(size); - memcpy(new_ptr, chunk->ptr, chunk->size); - chunk->ptr = new_ptr; - chunk->size = size; - chunk->pool = NULL; /* now we have no pool memory */ - pool->refcount--; - } - } - } else { - chunk->ptr = mnd_realloc(chunk->ptr, size); - } - DBG_VOID_RETURN; -} -/* }}} */ - - -/* {{{ mysqlnd_mempool_get_chunk */ -static -MYSQLND_MEMORY_POOL_CHUNK * mysqlnd_mempool_get_chunk(MYSQLND_MEMORY_POOL * pool, uint size TSRMLS_DC) -{ - MYSQLND_MEMORY_POOL_CHUNK *chunk = NULL; - DBG_ENTER("mysqlnd_mempool_get_chunk"); - - if (pool->free_chunk_list_elements) { - chunk = pool->free_chunk_list[--pool->free_chunk_list_elements]; - } else { - chunk = mnd_malloc(sizeof(MYSQLND_MEMORY_POOL_CHUNK)); - } - - chunk->free_chunk = mysqlnd_mempool_free_chunk; - chunk->resize_chunk = mysqlnd_mempool_resize_chunk; - chunk->size = size; - /* - Should not go over MYSQLND_MAX_PACKET_SIZE, since we - expect non-arena memory in mysqlnd_wireprotocol.c . We - realloc the non-arena memory. - */ - chunk->pool = pool; - if (size > pool->free_size) { - chunk->ptr = mnd_malloc(size); - chunk->from_pool = FALSE; - } else { - chunk->from_pool = TRUE; - ++pool->refcount; - chunk->ptr = pool->arena + (pool->arena_size - pool->free_size); - /* Last step, update free_size */ - pool->free_size -= size; - } - DBG_RETURN(chunk); -} -/* }}} */ -/************************************************************************************************/ - /* {{{ mysqlnd_library_init */ static @@ -274,13 +140,6 @@ void mysqlnd_library_init(TSRMLS_D) #ifdef ZTS mysqlnd_global_stats->LOCK_access = tsrm_mutex_alloc(); #endif - mysqlnd_memory_pool.arena_size = 16000; - mysqlnd_memory_pool.free_size = mysqlnd_memory_pool.arena_size; - mysqlnd_memory_pool.refcount = 0; - /* OOM ? */ - mysqlnd_memory_pool.arena = mnd_malloc(mysqlnd_memory_pool.arena_size); - mysqlnd_memory_pool.get_chunk = mysqlnd_mempool_get_chunk; - mysqlnd_memory_pool.free_contents = mysqlnd_mempool_free_contents; } } /* }}} */ @@ -291,9 +150,6 @@ static void mysqlnd_library_end(TSRMLS_D) { if (mysqlnd_library_initted == TRUE) { - /* mnd_free will reference LOCK_access and won't crash...*/ - mysqlnd_memory_pool.free_contents(&mysqlnd_memory_pool TSRMLS_CC); - free(mysqlnd_memory_pool.arena); #ifdef ZTS tsrm_mutex_free(mysqlnd_global_stats->LOCK_access); #endif @@ -422,6 +278,10 @@ MYSQLND_METHOD(mysqlnd_conn, free_contents)(MYSQLND *conn TSRMLS_DC) mysqlnd_palloc_free_thd_cache_reference(&conn->zval_cache); conn->zval_cache = NULL; } + if (conn->result_set_memory_pool) { + mysqlnd_mempool_destroy(conn->result_set_memory_pool TSRMLS_CC); + conn->result_set_memory_pool = NULL; + } if (conn->qcache) { DBG_INF("Freeing qcache reference"); mysqlnd_qcache_free_cache_reference(&conn->qcache); @@ -971,6 +831,7 @@ PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn, } DBG_INF_FMT("connection_id=%llu", conn->thread_id); + conn->result_set_memory_pool = mysqlnd_mempool_create(16000 TSRMLS_CC); #if PHP_MAJOR_VERSION >= 6 { uint as_unicode = 1; diff --git a/ext/mysqlnd/mysqlnd_block_alloc.c b/ext/mysqlnd/mysqlnd_block_alloc.c new file mode 100644 index 0000000000..4fc6178528 --- /dev/null +++ b/ext/mysqlnd/mysqlnd_block_alloc.c @@ -0,0 +1,201 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 6 | + +----------------------------------------------------------------------+ + | Copyright (c) 2006-2008 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Georg Richter | + | Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#include "php.h" +#include "mysqlnd.h" +#include "mysqlnd_block_alloc.h" +#include "mysqlnd_debug.h" +#include "mysqlnd_priv.h" + + +/* {{{ mysqlnd_mempool_free_chunk */ +static void +mysqlnd_mempool_free_contents(MYSQLND_MEMORY_POOL * pool TSRMLS_DC) +{ + DBG_ENTER("mysqlnd_mempool_dtor"); + uint i; + for (i = 0; i < pool->free_chunk_list_elements; i++) { + MYSQLND_MEMORY_POOL_CHUNK * chunk = pool->free_chunk_list[i]; + chunk->free_chunk(chunk, FALSE TSRMLS_CC); + } + + DBG_VOID_RETURN; +} +/* }}} */ + + +/* {{{ mysqlnd_mempool_free_chunk */ +static void +mysqlnd_mempool_free_chunk(MYSQLND_MEMORY_POOL_CHUNK * chunk, zend_bool cache_it TSRMLS_DC) +{ + DBG_ENTER("mysqlnd_mempool_free_chunk"); + MYSQLND_MEMORY_POOL * pool = chunk->pool; + if (chunk->from_pool) { + /* Try to back-off and guess if this is the last block allocated */ + if (chunk->ptr == (pool->arena + (pool->arena_size - pool->free_size - chunk->size))) { + /* + This was the last allocation. Lucky us, we can free + a bit of memory from the pool. Next time we will return from the same ptr. + */ + pool->free_size += chunk->size; + } + pool->refcount--; + } else { + mnd_free(chunk->ptr); + } + if (cache_it && pool->free_chunk_list_elements < MYSQLND_MEMORY_POOL_CHUNK_LIST_SIZE) { + chunk->ptr = NULL; + pool->free_chunk_list[pool->free_chunk_list_elements++] = chunk; + } else { + /* We did not cache it -> free it */ + mnd_free(chunk); + } + DBG_VOID_RETURN; +} +/* }}} */ + + +/* {{{ mysqlnd_mempool_resize_chunk */ +static void +mysqlnd_mempool_resize_chunk(MYSQLND_MEMORY_POOL_CHUNK * chunk, uint size TSRMLS_DC) +{ + DBG_ENTER("mysqlnd_mempool_resize_chunk"); + if (chunk->from_pool) { + MYSQLND_MEMORY_POOL * pool = chunk->pool; + /* Try to back-off and guess if this is the last block allocated */ + if (chunk->ptr == (pool->arena + (pool->arena_size - pool->free_size - chunk->size))) { + /* + This was the last allocation. Lucky us, we can free + a bit of memory from the pool. Next time we will return from the same ptr. + */ + if ((chunk->size + pool->free_size) < size) { + zend_uchar *new_ptr; + new_ptr = mnd_malloc(size); + memcpy(new_ptr, chunk->ptr, chunk->size); + chunk->ptr = new_ptr; + pool->free_size += chunk->size; + chunk->size = size; + chunk->pool = NULL; /* now we have no pool memory */ + pool->refcount--; + } else { + /* If the chunk is > than asked size then free_memory increases, otherwise decreases*/ + pool->free_size += (chunk->size - size); + } + } else { + /* Not last chunk, if the user asks for less, give it to him */ + if (chunk->size >= size) { + ; /* nop */ + } else { + zend_uchar *new_ptr; + new_ptr = mnd_malloc(size); + memcpy(new_ptr, chunk->ptr, chunk->size); + chunk->ptr = new_ptr; + chunk->size = size; + chunk->pool = NULL; /* now we have no pool memory */ + pool->refcount--; + } + } + } else { + chunk->ptr = mnd_realloc(chunk->ptr, size); + } + DBG_VOID_RETURN; +} +/* }}} */ + + +/* {{{ mysqlnd_mempool_get_chunk */ +static +MYSQLND_MEMORY_POOL_CHUNK * mysqlnd_mempool_get_chunk(MYSQLND_MEMORY_POOL * pool, uint size TSRMLS_DC) +{ + MYSQLND_MEMORY_POOL_CHUNK *chunk = NULL; + DBG_ENTER("mysqlnd_mempool_get_chunk"); + + if (pool->free_chunk_list_elements) { + chunk = pool->free_chunk_list[--pool->free_chunk_list_elements]; + } else { + chunk = mnd_malloc(sizeof(MYSQLND_MEMORY_POOL_CHUNK)); + } + + chunk->free_chunk = mysqlnd_mempool_free_chunk; + chunk->resize_chunk = mysqlnd_mempool_resize_chunk; + chunk->size = size; + /* + Should not go over MYSQLND_MAX_PACKET_SIZE, since we + expect non-arena memory in mysqlnd_wireprotocol.c . We + realloc the non-arena memory. + */ + chunk->pool = pool; + if (size > pool->free_size) { + chunk->ptr = mnd_malloc(size); + chunk->from_pool = FALSE; + } else { + chunk->from_pool = TRUE; + ++pool->refcount; + chunk->ptr = pool->arena + (pool->arena_size - pool->free_size); + /* Last step, update free_size */ + pool->free_size -= size; + } + DBG_RETURN(chunk); +} +/* }}} */ + + +/* {{{ mysqlnd_mempool_create */ +MYSQLND_MEMORY_POOL * +mysqlnd_mempool_create(size_t arena_size TSRMLS_DC) +{ + /* We calloc, because we free(). We don't mnd_calloc() for a reason. */ + MYSQLND_MEMORY_POOL * ret = mnd_calloc(1, sizeof(MYSQLND_MEMORY_POOL)); + DBG_ENTER("mysqlnd_mempool_create"); + + ret->free_size = ret->arena_size = arena_size; + ret->refcount = 0; + /* OOM ? */ + ret->arena = mnd_malloc(ret->arena_size); + ret->get_chunk = mysqlnd_mempool_get_chunk; + + DBG_RETURN(ret); +} +/* }}} */ + + +/* {{{ mysqlnd_mempool_destroy */ +void +mysqlnd_mempool_destroy(MYSQLND_MEMORY_POOL * pool TSRMLS_DC) +{ + DBG_ENTER("mysqlnd_mempool_destroy"); + /* mnd_free will reference LOCK_access and might crash, depending on the caller...*/ + mysqlnd_mempool_free_contents(pool TSRMLS_CC); + mnd_free(pool->arena); + DBG_VOID_RETURN; +} +/* }}} */ + + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/mysqlnd/mysqlnd_block_alloc.h b/ext/mysqlnd/mysqlnd_block_alloc.h new file mode 100644 index 0000000000..5c06a3f9d9 --- /dev/null +++ b/ext/mysqlnd/mysqlnd_block_alloc.h @@ -0,0 +1,39 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 6 | + +----------------------------------------------------------------------+ + | Copyright (c) 2006-2008 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Georg Richter | + | Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#ifndef MYSQLND_BLOCK_ALLOC_H +#define MYSQLND_BLOCK_ALLOC_H + +MYSQLND_MEMORY_POOL * mysqlnd_mempool_create(size_t arena_size TSRMLS_DC); +void mysqlnd_mempool_destroy(MYSQLND_MEMORY_POOL * pool TSRMLS_DC); + +#endif /* MYSQLND_BLOCK_ALLOC_H */ + + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/mysqlnd/mysqlnd_priv.h b/ext/mysqlnd/mysqlnd_priv.h index 7fcc2cd769..a0d4507988 100644 --- a/ext/mysqlnd/mysqlnd_priv.h +++ b/ext/mysqlnd/mysqlnd_priv.h @@ -183,9 +183,6 @@ extern struct st_mysqlnd_perm_bind mysqlnd_ps_fetch_functions[MYSQL_TYPE_LAST + extern const char * mysqlnd_out_of_sync; extern const char * mysqlnd_server_gone; -extern MYSQLND_MEMORY_POOL mysqlnd_memory_pool; - - enum_func_status mysqlnd_handle_local_infile(MYSQLND *conn, const char *filename, zend_bool *is_warning TSRMLS_DC); diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c index ca5be769c0..66728de205 100644 --- a/ext/mysqlnd/mysqlnd_ps.c +++ b/ext/mysqlnd/mysqlnd_ps.c @@ -1249,8 +1249,6 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_param)(MYSQLND_STMT * const stmt, static enum_func_status MYSQLND_METHOD(mysqlnd_stmt, refresh_bind_param)(MYSQLND_STMT * const stmt TSRMLS_DC) { - unsigned int i = 0; - DBG_ENTER("mysqlnd_stmt::refresh_bind_param"); DBG_INF_FMT("stmt=%lu param_count=%u", stmt->stmt_id, stmt->param_count); diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c index dccfdd7056..ea523a3623 100644 --- a/ext/mysqlnd/mysqlnd_result.c +++ b/ext/mysqlnd/mysqlnd_result.c @@ -585,6 +585,7 @@ unsigned long * mysqlnd_fetch_lengths_buffered(MYSQLND_RES * const result) /* }}} */ +#ifdef MYSQLND_THREADED /* {{{ mysqlnd_fetch_lengths_async_buffered */ /* Do lazy initialization for buffered results. As PHP strings have @@ -620,6 +621,7 @@ unsigned long * mysqlnd_fetch_lengths_async_buffered(MYSQLND_RES * const result) return result->lengths; } /* }}} */ +#endif /* {{{ mysqlnd_fetch_lengths_unbuffered */ diff --git a/ext/mysqlnd/mysqlnd_structs.h b/ext/mysqlnd/mysqlnd_structs.h index 4d81c287cc..8fca5f7ce3 100644 --- a/ext/mysqlnd/mysqlnd_structs.h +++ b/ext/mysqlnd/mysqlnd_structs.h @@ -41,7 +41,6 @@ struct st_mysqlnd_memory_pool uint free_chunk_list_elements; MYSQLND_MEMORY_POOL_CHUNK* (*get_chunk)(MYSQLND_MEMORY_POOL * pool, uint size TSRMLS_DC); - void (*free_contents)(MYSQLND_MEMORY_POOL * pool TSRMLS_DC); }; struct st_mysqlnd_memory_pool_chunk @@ -444,6 +443,8 @@ struct st_mysqlnd_connection /* qcache */ MYSQLND_QCACHE *qcache; + MYSQLND_MEMORY_POOL * result_set_memory_pool; + /* stats */ MYSQLND_STATS stats; diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c index 6015aac6eb..11a2719ea8 100644 --- a/ext/mysqlnd/mysqlnd_wireprotocol.c +++ b/ext/mysqlnd/mysqlnd_wireprotocol.c @@ -632,7 +632,8 @@ void php_mysqlnd_crypt(zend_uchar *buffer, const zend_uchar *s1, const zend_ucha /* {{{ php_mysqlnd_scramble */ -void php_mysqlnd_scramble(zend_uchar * const buffer, const zend_uchar * const scramble, const zend_uchar * const password) +void php_mysqlnd_scramble(zend_uchar * const buffer, const zend_uchar * const scramble, + const zend_uchar * const password) { PHP_SHA1_CTX context; unsigned char sha1[SHA1_MAX_LENGTH]; @@ -656,7 +657,7 @@ void php_mysqlnd_scramble(zend_uchar * const buffer, const zend_uchar * const sc PHP_SHA1Final(buffer, &context); /* let's crypt buffer now */ - php_mysqlnd_crypt(buffer, (const unsigned char *)buffer, (const unsigned char *)sha1, SHA1_MAX_LENGTH); + php_mysqlnd_crypt(buffer, (const uchar *)buffer, (const uchar *)sha1, SHA1_MAX_LENGTH); } /* }}} */ @@ -1267,7 +1268,8 @@ php_mysqlnd_read_row_ex(MYSQLND *conn, MYSQLND_MEMORY_POOL_CHUNK **buffer, We need a trailing \0 for the last string, in case of text-mode, to be able to implement read-only variables. Thus, we add + 1. */ - *buffer = mysqlnd_memory_pool.get_chunk(&mysqlnd_memory_pool, *data_size + 1 TSRMLS_CC); + *buffer = conn->result_set_memory_pool->get_chunk(conn->result_set_memory_pool, + *data_size + 1 TSRMLS_CC); p = (*buffer)->ptr; } else if (!first_iteration) { /* Empty packet after MYSQLND_MAX_PACKET_SIZE packet. That's ok, break */ @@ -1308,7 +1310,8 @@ php_mysqlnd_read_row_ex(MYSQLND *conn, MYSQLND_MEMORY_POOL_CHUNK **buffer, /* {{{ php_mysqlnd_rowp_read_binary_protocol */ void php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields, - uint field_count, MYSQLND_FIELD *fields_metadata, MYSQLND *conn TSRMLS_DC) + uint field_count, MYSQLND_FIELD *fields_metadata, + MYSQLND *conn TSRMLS_DC) { int i; zend_uchar *p = row_buffer->ptr; @@ -1362,7 +1365,8 @@ void php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffe /* {{{ php_mysqlnd_rowp_read_text_protocol */ void php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields, - uint field_count, MYSQLND_FIELD *fields_metadata, MYSQLND *conn TSRMLS_DC) + uint field_count, MYSQLND_FIELD *fields_metadata, + MYSQLND *conn TSRMLS_DC) { int i; zend_bool last_field_was_string = FALSE;