andrey Mon Jan 28 22:54:21 2008 UTC
Modified files:
/php-src/ext/mysql config.w32
/php-src/ext/mysqli/tests mysqli_get_client_stats.phpt
/php-src/ext/mysqlnd mysqlnd_block_alloc.c mysqlnd_block_alloc.h
config.w32 config9.m4 mysqlnd.c mysqlnd_priv.h
mysqlnd_ps.c mysqlnd_result.c
mysqlnd_structs.h mysqlnd_wireprotocol.c
Log:
MFB:
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.
http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/config.w32?r1=1.5&r2=1.6&diff_format=u
Index: php-src/ext/mysql/config.w32
diff -u php-src/ext/mysql/config.w32:1.5 php-src/ext/mysql/config.w32:1.6
--- php-src/ext/mysql/config.w32:1.5 Sat Jan 19 18:56:19 2008
+++ php-src/ext/mysql/config.w32 Mon Jan 28 22:54:21 2008
@@ -1,4 +1,4 @@
-// $Id: config.w32,v 1.5 2008/01/19 18:56:19 andrey Exp $
+// $Id: config.w32,v 1.6 2008/01/28 22:54:21 andrey Exp $
// vim:ft=javascript
ARG_WITH("mysql", "MySQL support", "no");
@@ -8,13 +8,15 @@
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');
}
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_stats.phpt?r1=1.4&r2=1.5&diff_format=u
Index: php-src/ext/mysqli/tests/mysqli_get_client_stats.phpt
diff -u php-src/ext/mysqli/tests/mysqli_get_client_stats.phpt:1.4
php-src/ext/mysqli/tests/mysqli_get_client_stats.phpt:1.5
--- php-src/ext/mysqli/tests/mysqli_get_client_stats.phpt:1.4 Mon Jan 28
18:27:49 2008
+++ php-src/ext/mysqli/tests/mysqli_get_client_stats.phpt Mon Jan 28
22:54:21 2008
@@ -969,9 +969,9 @@
["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 @@
[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"]=>
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_block_alloc.c?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_block_alloc.c
diff -u /dev/null php-src/ext/mysqlnd/mysqlnd_block_alloc.c:1.2
--- /dev/null Mon Jan 28 22:54:21 2008
+++ php-src/ext/mysqlnd/mysqlnd_block_alloc.c Mon Jan 28 22:54:21 2008
@@ -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 |
+ | [EMAIL PROTECTED] so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Georg Richter <[EMAIL PROTECTED]> |
+ | Andrey Hristov <[EMAIL PROTECTED]> |
+ | Ulf Wendel <[EMAIL PROTECTED]> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id: mysqlnd_block_alloc.c,v 1.2 2008/01/28 22:54:21 andrey Exp $ */
+
+#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
+ */
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_block_alloc.h?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_block_alloc.h
diff -u /dev/null php-src/ext/mysqlnd/mysqlnd_block_alloc.h:1.2
--- /dev/null Mon Jan 28 22:54:21 2008
+++ php-src/ext/mysqlnd/mysqlnd_block_alloc.h Mon Jan 28 22:54:21 2008
@@ -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 |
+ | [EMAIL PROTECTED] so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Georg Richter <[EMAIL PROTECTED]> |
+ | Andrey Hristov <[EMAIL PROTECTED]> |
+ | Ulf Wendel <[EMAIL PROTECTED]> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id: mysqlnd_block_alloc.h,v 1.2 2008/01/28 22:54:21 andrey Exp $ */
+
+#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
+ */
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/config.w32?r1=1.6&r2=1.7&diff_format=u
Index: php-src/ext/mysqlnd/config.w32
diff -u php-src/ext/mysqlnd/config.w32:1.6 php-src/ext/mysqlnd/config.w32:1.7
--- php-src/ext/mysqlnd/config.w32:1.6 Fri Nov 2 17:37:41 2007
+++ php-src/ext/mysqlnd/config.w32 Mon Jan 28 22:54:21 2008
@@ -1,15 +1,12 @@
-// $Id: config.w32,v 1.6 2007/11/02 17:37:41 stas Exp $
+// $Id: config.w32,v 1.7 2008/01/28 22:54:21 andrey Exp $
// 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 @@
"mysqlnd_wireprotocol.c";
EXTENSION("mysqlnd", mysqlnd_source, false);
}
-}
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/config9.m4?r1=1.4&r2=1.5&diff_format=u
Index: php-src/ext/mysqlnd/config9.m4
diff -u php-src/ext/mysqlnd/config9.m4:1.4 php-src/ext/mysqlnd/config9.m4:1.5
--- php-src/ext/mysqlnd/config9.m4:1.4 Mon Jan 28 18:27:49 2008
+++ php-src/ext/mysqlnd/config9.m4 Mon Jan 28 22:54:21 2008
@@ -1,5 +1,5 @@
dnl
-dnl $Id: config9.m4,v 1.4 2008/01/28 18:27:49 andrey Exp $
+dnl $Id: config9.m4,v 1.5 2008/01/28 22:54:21 andrey Exp $
dnl config.m4 for mysqlnd driver
dnl If some extension uses mysqlnd it will get compiled in PHP core
@@ -7,7 +7,8 @@
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)
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd.c?r1=1.12&r2=1.13&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd.c
diff -u php-src/ext/mysqlnd/mysqlnd.c:1.12 php-src/ext/mysqlnd/mysqlnd.c:1.13
--- php-src/ext/mysqlnd/mysqlnd.c:1.12 Mon Jan 28 18:27:49 2008
+++ php-src/ext/mysqlnd/mysqlnd.c Mon Jan 28 22:54:21 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mysqlnd.c,v 1.12 2008/01/28 18:27:49 andrey Exp $ */
+/* $Id: mysqlnd.c,v 1.13 2008/01/28 22:54:21 andrey Exp $ */
#include "php.h"
#include "mysqlnd.h"
#include "mysqlnd_wireprotocol.h"
@@ -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 @@
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 @@
/* }}} */
#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 @@
#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 @@
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_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 @@
}
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;
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_priv.h?r1=1.10&r2=1.11&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_priv.h
diff -u php-src/ext/mysqlnd/mysqlnd_priv.h:1.10
php-src/ext/mysqlnd/mysqlnd_priv.h:1.11
--- php-src/ext/mysqlnd/mysqlnd_priv.h:1.10 Mon Jan 28 18:27:49 2008
+++ php-src/ext/mysqlnd/mysqlnd_priv.h Mon Jan 28 22:54:21 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mysqlnd_priv.h,v 1.10 2008/01/28 18:27:49 andrey Exp $ */
+/* $Id: mysqlnd_priv.h,v 1.11 2008/01/28 22:54:21 andrey Exp $ */
#ifndef MYSQLND_PRIV_H
#define MYSQLND_PRIV_H
@@ -183,9 +183,6 @@
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);
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_ps.c?r1=1.9&r2=1.10&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_ps.c
diff -u php-src/ext/mysqlnd/mysqlnd_ps.c:1.9
php-src/ext/mysqlnd/mysqlnd_ps.c:1.10
--- php-src/ext/mysqlnd/mysqlnd_ps.c:1.9 Mon Jan 28 18:27:49 2008
+++ php-src/ext/mysqlnd/mysqlnd_ps.c Mon Jan 28 22:54:21 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mysqlnd_ps.c,v 1.9 2008/01/28 18:27:49 andrey Exp $ */
+/* $Id: mysqlnd_ps.c,v 1.10 2008/01/28 22:54:21 andrey Exp $ */
#include "php.h"
#include "mysqlnd.h"
#include "mysqlnd_wireprotocol.h"
@@ -1249,8 +1249,6 @@
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);
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_result.c?r1=1.12&r2=1.13&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_result.c
diff -u php-src/ext/mysqlnd/mysqlnd_result.c:1.12
php-src/ext/mysqlnd/mysqlnd_result.c:1.13
--- php-src/ext/mysqlnd/mysqlnd_result.c:1.12 Mon Jan 28 18:27:49 2008
+++ php-src/ext/mysqlnd/mysqlnd_result.c Mon Jan 28 22:54:21 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mysqlnd_result.c,v 1.12 2008/01/28 18:27:49 andrey Exp $ */
+/* $Id: mysqlnd_result.c,v 1.13 2008/01/28 22:54:21 andrey Exp $ */
#include "php.h"
#include "mysqlnd.h"
@@ -586,6 +586,7 @@
/* }}} */
+#ifdef MYSQLND_THREADED
/* {{{ mysqlnd_fetch_lengths_async_buffered */
/*
Do lazy initialization for buffered results. As PHP strings have
@@ -621,6 +622,7 @@
return result->lengths;
}
/* }}} */
+#endif
/* {{{ mysqlnd_fetch_lengths_unbuffered */
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_structs.h?r1=1.8&r2=1.9&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_structs.h
diff -u php-src/ext/mysqlnd/mysqlnd_structs.h:1.8
php-src/ext/mysqlnd/mysqlnd_structs.h:1.9
--- php-src/ext/mysqlnd/mysqlnd_structs.h:1.8 Mon Jan 28 18:27:49 2008
+++ php-src/ext/mysqlnd/mysqlnd_structs.h Mon Jan 28 22:54:21 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mysqlnd_structs.h,v 1.8 2008/01/28 18:27:49 andrey Exp $ */
+/* $Id: mysqlnd_structs.h,v 1.9 2008/01/28 22:54:21 andrey Exp $ */
#ifndef MYSQLND_STRUCTS_H
#define MYSQLND_STRUCTS_H
@@ -41,7 +41,6 @@
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 @@
/* qcache */
MYSQLND_QCACHE *qcache;
+ MYSQLND_MEMORY_POOL * result_set_memory_pool;
+
/* stats */
MYSQLND_STATS stats;
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_wireprotocol.c?r1=1.9&r2=1.10&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_wireprotocol.c
diff -u php-src/ext/mysqlnd/mysqlnd_wireprotocol.c:1.9
php-src/ext/mysqlnd/mysqlnd_wireprotocol.c:1.10
--- php-src/ext/mysqlnd/mysqlnd_wireprotocol.c:1.9 Mon Jan 28 18:27:49 2008
+++ php-src/ext/mysqlnd/mysqlnd_wireprotocol.c Mon Jan 28 22:54:21 2008
@@ -632,7 +632,8 @@
/* {{{ 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 @@
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 @@
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_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 @@
/* {{{ 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;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php