]> granicus.if.org Git - php/commitdiff
some config.w32 fixes
authorAndrey Hristov <andrey@php.net>
Mon, 28 Jan 2008 22:50:06 +0000 (22:50 +0000)
committerAndrey Hristov <andrey@php.net>
Mon, 28 Jan 2008 22:50:06 +0000 (22:50 +0000)
moved mysqlnd's block allocator to a separate file and also now
it's part of the connection, no MT problems.

12 files changed:
ext/mysql/config.w32
ext/mysqli/tests/mysqli_get_client_stats.phpt
ext/mysqlnd/config.w32
ext/mysqlnd/config9.m4
ext/mysqlnd/mysqlnd.c
ext/mysqlnd/mysqlnd_block_alloc.c [new file with mode: 0644]
ext/mysqlnd/mysqlnd_block_alloc.h [new file with mode: 0644]
ext/mysqlnd/mysqlnd_priv.h
ext/mysqlnd/mysqlnd_ps.c
ext/mysqlnd/mysqlnd_result.c
ext/mysqlnd/mysqlnd_structs.h
ext/mysqlnd/mysqlnd_wireprotocol.c

index a36ba1709c657e87cfebacbcc676112e79edcb06..df3f3556cb4b13ab7915f475b83ab5bde3a6c873 100644 (file)
@@ -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');
 }
index 10cad1e72793013a2657c914961f6978c85c0939..042f14bd99c43b06b9630582d53ae4de41fca508 100644 (file)
@@ -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"]=>
index a01f00d2264104c8abdf90349e805d49f9c48f57..8935287b5f48f2f08fd54babe3d2af75f55f3551 100644 (file)
@@ -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
index 9d09ba71dab518163055a2bfa8d18b3688f6afdf..2a5c3305956c10fb40391c734bf5a2575f819bfc 100644 (file)
@@ -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)
index 6e7441dceab52b9b9bb73496bf0a883715d12c4f..2408f8fb8b9313004a188d55693d49b5e1864cd4 100644 (file)
@@ -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 (file)
index 0000000..4fc6178
--- /dev/null
@@ -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 <georg@mysql.com>                             |
+  |          Andrey Hristov <andrey@mysql.com>                           |
+  |          Ulf Wendel <uwendel@mysql.com>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $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 (file)
index 0000000..5c06a3f
--- /dev/null
@@ -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 <georg@mysql.com>                             |
+  |          Andrey Hristov <andrey@mysql.com>                           |
+  |          Ulf Wendel <uwendel@mysql.com>                              |
+  +----------------------------------------------------------------------+
+*/
+
+/* $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
+ */
index 7fcc2cd7694789046172dc03033e2d14d35a88ba..a0d45079883f192c7688bb270e52676232e270ad 100644 (file)
@@ -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);
 
 
index ca5be769c00ca8c5cc452cf557a4f8778f33cc6f..66728de2052cd99f570fcde54d663a6f0b95467f 100644 (file)
@@ -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);
 
index dccfdd70569eacabf31a3afb6df1e5dd184f8ef0..ea523a362387b9288de8894a3428a929bbd71bc9 100644 (file)
@@ -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 */
index 4d81c287ccd36626ac16c2c2b1e1ed38e48e2a65..8fca5f7ce361b5f53e0b7d84e8b11dd4451c72d9 100644 (file)
@@ -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;
 
index 6015aac6ebce6c222bbd21f291e5a9a7b0d052dc..11a2719ea86c4176f5d931e7b67cefefa29d91b7 100644 (file)
@@ -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;