List:Commits« Previous MessageNext Message »
From:ahristov Date:April 30 2007 10:18pm
Subject:PHP mysqlnd svn commit: r358 - in trunk: mysqlnd php5/ext/mysqli php6/ext/mysqli
View as plain text  
Author: ahristov
Date: 2007-04-30 22:18:22 +0200 (Mon, 30 Apr 2007)
New Revision: 358

Modified:
   trunk/mysqlnd/mysqlnd.c
   trunk/mysqlnd/mysqlnd.h
   trunk/mysqlnd/mysqlnd_palloc.c
   trunk/mysqlnd/mysqlnd_palloc.h
   trunk/mysqlnd/mysqlnd_priv.h
   trunk/mysqlnd/mysqlnd_ps.c
   trunk/php5/ext/mysqli/mysqli.c
   trunk/php5/ext/mysqli/mysqli_api.c
   trunk/php5/ext/mysqli/mysqli_nonapi.c
   trunk/php5/ext/mysqli/php_mysqli.h
   trunk/php6/ext/mysqli/mysqli.c
   trunk/php6/ext/mysqli/mysqli_api.c
   trunk/php6/ext/mysqli/mysqli_nonapi.c
   trunk/php6/ext/mysqli/php_mysqli.h
Log:
Separate the GC (Garbage collection) list from the global
persistent zval cache. Every thread has its own list. When not
multithreaded this will mean two structures. This skips the looping
over the whole cache but only goes over the GC list at the end of the request.
Still jumping from 2k to 100k entries in the list decreases the performance
with 25%, which should be checked. But don't make your cache too big. 100k
zvals is an extreme case.

Also fixed a problem with character set under Unicode mode. We should initialize
the connection from the beginning as Utf8, swedish collation, so the user can
authenticate with non-latin1 username too.


Modified: trunk/mysqlnd/mysqlnd.c
===================================================================
--- trunk/mysqlnd/mysqlnd.c	2007-04-27 20:15:15 UTC (rev 357)
+++ trunk/mysqlnd/mysqlnd.c	2007-04-30 20:18:22 UTC (rev 358)
@@ -156,7 +156,7 @@
 /* {{{ mysqlnd_free_buffered_data */
 void mysqlnd_free_buffered_data(MYSQLND_RES *result TSRMLS_DC)
 {
-	MYSQLND_ZVAL_PCACHE  *zval_cache = result->zval_cache;
+	MYSQLND_THD_ZVAL_PCACHE  *zval_cache = result->zval_cache;
 	MYSQLND_RES_BUFFERED *set = result->data;
 	enum_mysqlnd_res_type result_type = result->type;
 	unsigned int field_count = result->field_count;
@@ -184,7 +184,7 @@
 	set->row_buffers	= NULL;
 	set->data_cursor	= NULL;
 	set->row_count	= 0;
-	if (set->persistent) {
+	if (set->qcache) {
 		mysqlnd_qcache_free_cache_reference(&set->qcache);
 	}
 	pefree(set, set->persistent);
@@ -269,7 +269,7 @@
 	}
 
 	if (result->zval_cache) {
-		mysqlnd_palloc_free_cache_reference(&result->zval_cache);
+		mysqlnd_palloc_free_thd_cache_reference(&result->zval_cache);
 		result->zval_cache = NULL;
 	}
 }
@@ -383,7 +383,7 @@
 		conn->options.ssl_cipher = NULL;
 	}
 	if (conn->zval_cache) {
-		mysqlnd_palloc_free_cache_reference(&conn->zval_cache);
+		mysqlnd_palloc_free_thd_cache_reference(&conn->zval_cache);
 		conn->zval_cache = NULL;
 	}
 	if (conn->qcache) {
@@ -591,7 +591,7 @@
 						 unsigned int port,
 						 char *socket,
 						 unsigned int mysql_flags,
-						 MYSQLND_ZVAL_PCACHE *zval_cache
+						 MYSQLND_THD_ZVAL_PCACHE *zval_cache
 						 TSRMLS_DC)
 {
 	char *transport = NULL, *errstr = NULL;
@@ -712,7 +712,14 @@
 
 	auth_packet->user		= user;
 	auth_packet->password	= passwd;
-	auth_packet->charset_no	= greet_packet.charset_no;
+#if PHP_MAJOR_VERSION >= 6
+	if (UG(unicode)) {
+		auth_packet->charset_no	= 200;/* utf8 - swedish collation, check mysqlnd_charset.c
*/	
+	} else
+#endif
+	{
+		auth_packet->charset_no	= greet_packet.charset_no;	
+	}
 	auth_packet->db			= db;
 	auth_packet->db_len		= db_len;
 	auth_packet->max_packet_size= 3UL*1024UL*1024UL*1024UL;
@@ -778,7 +785,7 @@
 		PACKET_FREE(auth_packet);
 		PACKET_FREE_ALLOCA(ok_packet);
 
-		conn->zval_cache = mysqlnd_palloc_get_cache_reference(zval_cache);
+		conn->zval_cache = mysqlnd_palloc_get_thd_cache_reference(zval_cache);
 		conn->net.cmd_buffer.length = 128L*1024L;
 		conn->net.cmd_buffer.buffer = pemalloc(conn->net.cmd_buffer.length,
conn->persistent);
 
@@ -1103,7 +1110,7 @@
 					result =
 						conn->current_result=
 							mysqlnd_result_init(rset_header.field_count,
-												mysqlnd_palloc_get_cache_reference(conn->zval_cache));
+												mysqlnd_palloc_get_thd_cache_reference(conn->zval_cache));
 				} else {
 					if (!stmt->result) {
 						/*
@@ -1115,7 +1122,7 @@
 						result =
 							stmt->result =
 								mysqlnd_result_init(rset_header.field_count,
-													mysqlnd_palloc_get_cache_reference(conn->zval_cache));
+													mysqlnd_palloc_get_thd_cache_reference(conn->zval_cache));
 					} else {
 						/*
 						  Update result set metadata if it for some reason changed between
@@ -2719,7 +2726,7 @@
 
 
 /* {{{ mysqlnd_result_init */
-MYSQLND_RES *mysqlnd_result_init(unsigned int field_count, MYSQLND_ZVAL_PCACHE *cache)
+MYSQLND_RES *mysqlnd_result_init(unsigned int field_count, MYSQLND_THD_ZVAL_PCACHE
*cache)
 {
 	MYSQLND_RES *ret = ecalloc(1, sizeof(MYSQLND_RES));
 

Modified: trunk/mysqlnd/mysqlnd.h
===================================================================
--- trunk/mysqlnd/mysqlnd.h	2007-04-27 20:15:15 UTC (rev 357)
+++ trunk/mysqlnd/mysqlnd.h	2007-04-30 20:18:22 UTC (rev 358)
@@ -405,6 +405,7 @@
 
 
 typedef struct st_mysqlnd_zval_pcache	MYSQLND_ZVAL_PCACHE;
+typedef struct st_mysqlnd_thread_zval_pcache	MYSQLND_THD_ZVAL_PCACHE;
 typedef struct st_mysqlnd_qcache		MYSQLND_QCACHE;
 
 
@@ -690,7 +691,7 @@
 	MYSQLND_OPTION	options;
 
 	/* zval cache */
-	MYSQLND_ZVAL_PCACHE	*zval_cache;
+	MYSQLND_THD_ZVAL_PCACHE	*zval_cache;
 
 	/* qcache */
 	MYSQLND_QCACHE		*qcache;
@@ -767,7 +768,7 @@
 	php_mysql_packet_row	*row_packet;	/* Unused for PS */
 
 	/* zval cache */
-	MYSQLND_ZVAL_PCACHE		*zval_cache;
+	MYSQLND_THD_ZVAL_PCACHE		*zval_cache;
 
 	struct st_mysqlnd_res_methods m;
 };
@@ -841,7 +842,7 @@
 						  unsigned int port,
 						  char *socket,
 						  unsigned int mysql_flags,
-						  MYSQLND_ZVAL_PCACHE *zval_cache
+						  MYSQLND_THD_ZVAL_PCACHE *zval_cache
 						  TSRMLS_DC);
 #define mysqlnd_change_user(conn, user, passwd, db)		(conn)->m->change_user((conn),
(user), (passwd), (db) TSRMLS_CC)
 
@@ -1020,15 +1021,21 @@
 
 /* Persistent caching zval allocator */
 PHPAPI MYSQLND_ZVAL_PCACHE* mysqlnd_palloc_init_cache(unsigned int cache_size);
-MYSQLND_ZVAL_PCACHE* mysqlnd_palloc_get_cache_reference(MYSQLND_ZVAL_PCACHE * const
cache);
-PHPAPI void			mysqlnd_palloc_free_cache_reference(MYSQLND_ZVAL_PCACHE **cache);
-PHPAPI void			mysqlnd_palloc_rinit(MYSQLND_ZVAL_PCACHE * const cache);
-PHPAPI void			mysqlnd_palloc_rshutdown(MYSQLND_ZVAL_PCACHE * const cache);
+PHPAPI void 		mysqlnd_palloc_free_cache(MYSQLND_ZVAL_PCACHE *cache);
 PHPAPI void			mysqlnd_palloc_stats(const MYSQLND_ZVAL_PCACHE * const cache, zval
*return_value);
 
+PHPAPI MYSQLND_THD_ZVAL_PCACHE * mysqlnd_palloc_rinit(MYSQLND_ZVAL_PCACHE * cache);
+PHPAPI void						 mysqlnd_palloc_rshutdown(MYSQLND_THD_ZVAL_PCACHE * cache);
+
+
+MYSQLND_THD_ZVAL_PCACHE*	mysqlnd_palloc_init_thd_cache(MYSQLND_ZVAL_PCACHE * const
cache);
+MYSQLND_THD_ZVAL_PCACHE*	mysqlnd_palloc_get_thd_cache_reference(MYSQLND_THD_ZVAL_PCACHE *
const cache);
+PHPAPI void					mysqlnd_palloc_free_thd_cache_reference(MYSQLND_THD_ZVAL_PCACHE **cache);
+
+
 /* There two should not be used from outside */
-void *				mysqlnd_palloc_get_zval(MYSQLND_ZVAL_PCACHE * const cache, zend_bool
*allocated);
-void				mysqlnd_palloc_zval_ptr_dtor(zval **zv, MYSQLND_ZVAL_PCACHE * const cache,
zend_bool ps,
+void *				mysqlnd_palloc_get_zval(MYSQLND_THD_ZVAL_PCACHE * const cache, zend_bool
*allocated);
+void				mysqlnd_palloc_zval_ptr_dtor(zval **zv, MYSQLND_THD_ZVAL_PCACHE * const cache,
zend_bool ps,
 												 zend_bool *copy_ctor_called TSRMLS_DC);
 
 

Modified: trunk/mysqlnd/mysqlnd_palloc.c
===================================================================
--- trunk/mysqlnd/mysqlnd_palloc.c	2007-04-27 20:15:15 UTC (rev 357)
+++ trunk/mysqlnd/mysqlnd_palloc.c	2007-04-30 20:18:22 UTC (rev 358)
@@ -65,16 +65,6 @@
 	ret->free_list.ptr_line = calloc(ret->max_items + 1, sizeof(mysqlnd_zval *));
 	ret->free_list.last_added = ret->free_list.ptr_line + ret->max_items;
 
-	/* 2. Initialize the GC list */
-	ret->gc_list.ptr_line = calloc(ret->max_items, sizeof(mysqlnd_zval *));
-	/* Backward and forward looping is possible */
-	ret->gc_list.last_added = ret->gc_list.ptr_line;
-
-	/* Backward and forward looping is possible */
-	ret->swap_gc_list.ptr_line = calloc(ret->max_items, sizeof(mysqlnd_zval *));
-	ret->swap_gc_list.last_added = ret->swap_gc_list.ptr_line;
-
-
 	/* 3. Allocate and initialize our zvals and initialize the free list */
 	ret->block = calloc(ret->max_items, sizeof(mysqlnd_zval));
 	ret->last_in_block = &(ret->block[ret->max_items]);
@@ -115,7 +105,6 @@
   to the free list after usage. We ZVAL_NULL() them when we allocate them in the 
   constructor of the cache.
 */
-static
 void mysqlnd_palloc_free_cache(MYSQLND_ZVAL_PCACHE *cache)
 {
 #ifndef MYSQLND_SILENT
@@ -129,27 +118,80 @@
 	/* Data in pointed by 'block' was cleaned in RSHUTDOWN */
 	free(cache->block);
 	free(cache->free_list.ptr_line);
+	free(cache);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_palloc_init_thd_cache */
+PHPAPI MYSQLND_THD_ZVAL_PCACHE* mysqlnd_palloc_init_thd_cache(MYSQLND_ZVAL_PCACHE * const
cache)
+{
+	MYSQLND_THD_ZVAL_PCACHE *ret = calloc(1, sizeof(MYSQLND_THD_ZVAL_PCACHE));
+#ifndef MYSQLND_SILENT
+	php_printf("[mysqlnd_palloc_init_thd_cache %p]\n", ret);
+#endif
+	ret->parent = mysqlnd_palloc_get_cache_reference(cache);
+
+#ifdef ZTS
+	ret->thread_id = tsrm_thread_id();
+#endif
+
+	ret->references = 1;
+
+	/* 1. Initialize the GC list */
+	ret->gc_list.ptr_line = calloc(cache->max_items, sizeof(mysqlnd_zval *));
+	/* Backward and forward looping is possible */
+	ret->gc_list.last_added = ret->gc_list.ptr_line;
+
+	return ret;
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_palloc_get_thd_cache_reference */
+MYSQLND_THD_ZVAL_PCACHE* mysqlnd_palloc_get_thd_cache_reference(MYSQLND_THD_ZVAL_PCACHE *
const cache)
+{
+	if (cache) {
+		++cache->references;
+		mysqlnd_palloc_get_cache_reference(cache->parent);
+	}
+	return cache;
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_palloc_free_cache */
+/*
+  As this call will happen on MSHUTDOWN(), then we don't need to copy the zvals with
+  copy_ctor but scrap what they point to with zval_dtor() and then just free our
+  pre-allocated block. Precondition is that we ZVAL_NULL() the zvals when we put them
+  to the free list after usage. We ZVAL_NULL() them when we allocate them in the 
+  constructor of the cache.
+*/
+static
+void mysqlnd_palloc_free_thd_cache(MYSQLND_THD_ZVAL_PCACHE *cache)
+{
+#ifndef MYSQLND_SILENT
+	php_printf("[mysqlnd_palloc_free_thd_cache %p]\n", cache);
+#endif
+
 	free(cache->gc_list.ptr_line);
-	free(cache->swap_gc_list.ptr_line);
 	free(cache);
 }
 /* }}} */
 
 
-/* {{{ mysqlnd_palloc_free_cache_reference */
-PHPAPI void mysqlnd_palloc_free_cache_reference(MYSQLND_ZVAL_PCACHE **cache)
+/* {{{ mysqlnd_palloc_free_thd_cache_reference */
+PHPAPI void mysqlnd_palloc_free_thd_cache_reference(MYSQLND_THD_ZVAL_PCACHE **cache)
 {
 	if (*cache) {
-		zend_bool to_free;
 #ifndef MYSQLND_SILENT
-		php_printf("[mysqlnd_palloc_free_cache_reference %p] refs=%d\n", *cache,
(*cache)->references);
+		php_printf("[mysqlnd_palloc_free_thd_cache_reference %p] refs=%d\n", *cache,
(*cache)->references);
 #endif
-		LOCK_PCACHE(*cache);
-		to_free = --(*cache)->references == 0;
-		/* Unlock before destroying */
-		UNLOCK_PCACHE(*cache);
-		if (to_free) {
-			mysqlnd_palloc_free_cache(*cache);
+		--(*cache)->parent->references;
+
+		if (--(*cache)->references == 0) {
+			mysqlnd_palloc_free_thd_cache(*cache);
 		}
 		*cache = NULL;
 	}
@@ -243,7 +285,7 @@
 
 
 /* {{{ mysqlnd_palloc_get_zval */
-void *mysqlnd_palloc_get_zval(MYSQLND_ZVAL_PCACHE * const cache, zend_bool *allocated)
+void *mysqlnd_palloc_get_zval(MYSQLND_THD_ZVAL_PCACHE * const thd_cache, zend_bool
*allocated)
 {
 	void *ret = NULL;
 
@@ -252,13 +294,15 @@
 				cache, cache? cache->free_list.last_added:NULL, cache->free_items);
 #endif
 
-	if (cache) {
+	if (thd_cache) {
+		MYSQLND_ZVAL_PCACHE *cache = thd_cache->parent;
 		LOCK_PCACHE(cache);
+		
 		if ((ret = *cache->free_list.last_added)) {
 			*cache->free_list.last_added++ = NULL;
 			*allocated = FALSE;
 #ifdef ZTS
-		    ((mysqlnd_zval *) ret)->thread_id = tsrm_thread_id();
+			((mysqlnd_zval *) ret)->thread_id = thd_cache->thread_id;
 #endif
 			--cache->free_items;
 			++cache->get_hits;
@@ -289,15 +333,17 @@
 
 
 /* {{{ mysqlnd_palloc_zval_ptr_dtor */
-void mysqlnd_palloc_zval_ptr_dtor(zval **zv, MYSQLND_ZVAL_PCACHE * const cache, zend_bool
ps,
+void mysqlnd_palloc_zval_ptr_dtor(zval **zv, MYSQLND_THD_ZVAL_PCACHE * const thd_cache,
zend_bool ps,
 								  zend_bool *copy_ctor_called TSRMLS_DC)
 {
+	MYSQLND_ZVAL_PCACHE *cache;
 #ifndef MYSQLND_SILENT
 	php_printf("[mysqlnd_palloc_zval_ptr_dtor %p] *zv=%p ps=%d refc=%d\n", cache, *zv, ps,
ZVAL_REFCOUNT(*zv));
 #endif
 	*copy_ctor_called = FALSE;
 	/* Check whether cache is used and the zval is from the cache */
-	if (!cache || ((char *)*zv < (char *)cache->block || (char *)*zv > (char
*)cache->last_in_block)) {
+	if (!thd_cache || !(cache = thd_cache->parent) || ((char *)*zv < (char
*)thd_cache->parent->block ||
+													   (char *)*zv > (char *)thd_cache->parent->last_in_block)) {
 		/* 
 		  This zval is not from the cache block.
 		  Thus the refcount is -1 than of a zval from the cache,
@@ -380,7 +426,7 @@
 		*/
 		LOCK_PCACHE(cache);
 		++cache->put_misses;
-//		*(cache->gc_list.last_added++) = (mysqlnd_zval *)*zv;
+		*(thd_cache->gc_list.last_added++) = (mysqlnd_zval *)*zv;
 		UNLOCK_PCACHE(cache);
 	} else {
 		/* No user reference */
@@ -406,58 +452,50 @@
 
 
 /* {{{ mysqlnd_palloc_rinit */
-PHPAPI void mysqlnd_palloc_rinit(MYSQLND_ZVAL_PCACHE * const cache)
+PHPAPI MYSQLND_THD_ZVAL_PCACHE * mysqlnd_palloc_rinit(MYSQLND_ZVAL_PCACHE * cache)
 {
-	return;
+	return mysqlnd_palloc_init_thd_cache(cache);
 }
 /* }}} */
 
 
 /* {{{ mysqlnd_palloc_rshutdown */
-PHPAPI void mysqlnd_palloc_rshutdown(MYSQLND_ZVAL_PCACHE * const cache)
+PHPAPI void mysqlnd_palloc_rshutdown(MYSQLND_THD_ZVAL_PCACHE * thd_cache)
 {
-	unsigned int i;
-#ifdef ZTS
-	THREAD_T thread_id;
-#endif
+	MYSQLND_ZVAL_PCACHE *cache;
+	mysqlnd_zval **p;
 #ifndef MYSQLND_SILENT
 	php_printf("[mysqlnd_palloc_rshutdown %p]\n", cache);
 #endif
-	if (!cache) {
+	if (!thd_cache || !(cache = thd_cache->parent)) {
 		return;
 	}
 
-#ifdef ZTS
-	thread_id = tsrm_thread_id();
-#endif
 	/*
 	  Keep in mind that for pthreads pthread_equal() should be used to be
 	  fully standard compliant. However, the PHP code all-around, incl. the
 	  the Zend MM uses direct comparison.
 	*/
+	p = thd_cache->gc_list.ptr_line;
+	while (p < thd_cache->gc_list.last_added) {
+		zval_dtor(&(*p)->zv);
+		p++;
+	}
+
+	p = thd_cache->gc_list.ptr_line;
 	LOCK_PCACHE(cache);
-	for (i = 0; i < cache->max_items; i++) {
-		if (
-			cache->block[i].point_type == MYSQLND_POINTS_EXT_BUFFER
+	while (p < thd_cache->gc_list.last_added) {
+		(*p)->point_type = MYSQLND_POINTS_FREE;
+		*(--cache->free_list.last_added) = *p;
+		++cache->free_items;
 #ifdef ZTS
-#if defined(PTHREADS)
-			&& pthread_equal(cache->block[i].thread_id, thread_id)
-#else
-			&& cache->block[i].thread_id == thread_id
-#endif
-#endif
-			)
-		{
-			zval_dtor(&(cache->block[i].zv));
-			cache->block[i].point_type = MYSQLND_POINTS_FREE;
-			*(--cache->free_list.last_added) = &(cache->block[i]);
-			++cache->free_items;
-#ifdef ZTS
-			memset(&cache->block[i].thread_id, 0, sizeof(THREAD_T));
-#endif
-		}
+		memset(&((*p)->thread_id), 0, sizeof(THREAD_T));
+#endif	
+		p++;
 	}
 	UNLOCK_PCACHE(cache);
+
+	mysqlnd_palloc_free_thd_cache_reference(&thd_cache);
 }
 /* }}} */
 
@@ -515,4 +553,3 @@
 	}
 }
 /* }}} */
-

Modified: trunk/mysqlnd/mysqlnd_palloc.h
===================================================================
--- trunk/mysqlnd/mysqlnd_palloc.h	2007-04-27 20:15:15 UTC (rev 357)
+++ trunk/mysqlnd/mysqlnd_palloc.h	2007-04-30 20:18:22 UTC (rev 358)
@@ -71,17 +71,15 @@
 	mysqlnd_zval		*block;
 	mysqlnd_zval		*last_in_block;
 	mysqlnd_ndzval_list	free_list;	/* Fetch from here */
-	mysqlnd_ndzval_list	gc_list;	/* GC these from time to time */
-	mysqlnd_ndzval_list	swap_gc_list;	/* Temporal storage during rshutdown */
 
-
 #ifdef ZTS
 	MUTEX_T 			LOCK_access;
 #endif
+	unsigned int		references;
+
 	/* These are just for statistics and not used for operational purposes */
 	unsigned int		free_items;
 	unsigned int		max_items;
-	unsigned int		references;
 
 	unsigned long		get_hits;
 	unsigned long		get_misses;
@@ -89,5 +87,14 @@
 	unsigned long		put_misses;
 };
 
+struct st_mysqlnd_thread_zval_pcache {
+	struct st_mysqlnd_zval_pcache *parent;
 
+	unsigned int		references;
+#ifdef ZTS
+	THREAD_T			thread_id;
+#endif
+	mysqlnd_ndzval_list	gc_list;		/* GC these from time to time */
+};
+
 #endif /* MYSQLND_PALLOC_H */

Modified: trunk/mysqlnd/mysqlnd_priv.h
===================================================================
--- trunk/mysqlnd/mysqlnd_priv.h	2007-04-27 20:15:15 UTC (rev 357)
+++ trunk/mysqlnd/mysqlnd_priv.h	2007-04-30 20:18:22 UTC (rev 358)
@@ -156,7 +156,7 @@
 
 enum_func_status mysqlnd_read_result_metadata(MYSQLND *conn, MYSQLND_RES *result
TSRMLS_DC);
 
-MYSQLND_RES *mysqlnd_result_init(unsigned int field_count, MYSQLND_ZVAL_PCACHE
*cache);							
+MYSQLND_RES *mysqlnd_result_init(unsigned int field_count, MYSQLND_THD_ZVAL_PCACHE
*cache);							
 void mysqlnd_unbuffered_free_last_data(MYSQLND_RES *result TSRMLS_DC);
 void mysqlnd_internal_free_result_contents(MYSQLND_RES *result TSRMLS_DC);
 void mysqlnd_internal_free_result_buffers(MYSQLND_RES *result TSRMLS_DC);

Modified: trunk/mysqlnd/mysqlnd_ps.c
===================================================================
--- trunk/mysqlnd/mysqlnd_ps.c	2007-04-27 20:15:15 UTC (rev 357)
+++ trunk/mysqlnd/mysqlnd_ps.c	2007-04-30 20:18:22 UTC (rev 358)
@@ -1160,7 +1160,7 @@
 MYSQLND_RES * _mysqlnd_stmt_result_metadata(MYSQLND_STMT * const stmt)
 {
 	MYSQLND_RES *result;
-	MYSQLND_ZVAL_PCACHE * cache;
+	MYSQLND_THD_ZVAL_PCACHE * cache;
 
 	if (!stmt->field_count || !stmt->conn || !stmt->result) {
 		return NULL;
@@ -1173,7 +1173,7 @@
 			be handled in a better way.
 	
 	*/
-	cache = mysqlnd_palloc_get_cache_reference(stmt->conn->zval_cache);
+	cache = mysqlnd_palloc_get_thd_cache_reference(stmt->conn->zval_cache);
 	result = mysqlnd_result_init(stmt->field_count, cache);
 	result->type = MYSQLND_RES_NORMAL;
 	result->m.fetch_row = result->m.fetch_row_normal_unbuffered;

Modified: trunk/php5/ext/mysqli/mysqli.c
===================================================================
--- trunk/php5/ext/mysqli/mysqli.c	2007-04-27 20:15:15 UTC (rev 357)
+++ trunk/php5/ext/mysqli/mysqli.c	2007-04-30 20:18:22 UTC (rev 358)
@@ -501,7 +501,7 @@
 	STD_PHP_INI_ENTRY("mysqli.default_socket",			NULL,	PHP_INI_ALL,		OnUpdateStringUnempty,	default_socket,	zend_mysqli_globals,		mysqli_globals)
 	STD_PHP_INI_BOOLEAN("mysqli.reconnect",				"0",	PHP_INI_SYSTEM,		OnUpdateLong,		reconnect,			zend_mysqli_globals,		mysqli_globals)
 #ifdef HAVE_MYSQLND
-	STD_PHP_INI_ENTRY("mysqli.cache_size",			   
"2000",	PHP_INI_SYSTEM,		OnUpdateLong,		cache_size,			zend_mysqli_globals,		mysqli_globals)
+	STD_PHP_INI_ENTRY("mysqli.cache_size",				"2000",	PHP_INI_SYSTEM,		OnUpdateLong,		cache_size,			zend_mysqli_globals,		mysqli_globals)
 #endif
 PHP_INI_END()
 
@@ -528,11 +528,8 @@
 #endif
 #ifdef HAVE_MYSQLND
 	mysqli_globals->cache_size = 0;
+	mysqli_globals->mysqlnd_thd_zval_cache = NULL;
 #endif
-#ifdef HAVE_MYSQLND
-    mysqlnd_zval_cache = NULL;
-    mysqlnd_qcache = NULL;
-#endif
 }
 /* }}} */
 
@@ -728,7 +725,8 @@
 	zend_hash_destroy(&mysqli_link_properties);
 	zend_hash_destroy(&classes);
 #ifdef HAVE_MYSQLND
-	mysqlnd_palloc_free_cache_reference(&mysqlnd_zval_cache);
+	mysqlnd_palloc_free_cache(mysqlnd_zval_cache);
+	mysqlnd_qcache_free_cache_reference(&mysqlnd_qcache);
 	mysqlnd_library_end();
 #endif
 
@@ -744,7 +742,7 @@
 	MyG(error_msg) = NULL;
 	MyG(error_no) = 0;
 #ifdef HAVE_MYSQLND
-	mysqlnd_palloc_rinit(mysqlnd_zval_cache);
+	MyG(mysqlnd_thd_zval_cache) = mysqlnd_palloc_rinit(mysqlnd_zval_cache);
 #endif
 
 	return SUCCESS;
@@ -759,7 +757,7 @@
 		efree(MyG(error_msg));
 	}
 #ifdef HAVE_MYSQLND
-	mysqlnd_palloc_rshutdown(mysqlnd_zval_cache);
+	mysqlnd_palloc_rshutdown(MyG(mysqlnd_thd_zval_cache));
 #endif
 	return SUCCESS;
 }

Modified: trunk/php5/ext/mysqli/mysqli_api.c
===================================================================
--- trunk/php5/ext/mysqli/mysqli_api.c	2007-04-27 20:15:15 UTC (rev 357)
+++ trunk/php5/ext/mysqli/mysqli_api.c	2007-04-30 20:18:22 UTC (rev 358)
@@ -1633,7 +1633,7 @@
 	if (mysql_real_connect(mysql->mysql, hostname, username, passwd, dbname ,port, socket
,flags) == NULL) 
 #else
 	if (mysqlnd_connect(mysql->mysql, hostname, username, passwd, passwd_len, dbname,
dbname_len,
-						  port, socket, flags, mysqlnd_zval_cache TSRMLS_CC) == NULL)
+						  port, socket, flags, MyG(mysqlnd_thd_zval_cache) TSRMLS_CC) == NULL)
 #endif
 	{
 		php_mysqli_set_error(mysql_errno(mysql->mysql), (char *)
mysql_error(mysql->mysql) TSRMLS_CC);

Modified: trunk/php5/ext/mysqli/mysqli_nonapi.c
===================================================================
--- trunk/php5/ext/mysqli/mysqli_nonapi.c	2007-04-27 20:15:15 UTC (rev 357)
+++ trunk/php5/ext/mysqli/mysqli_nonapi.c	2007-04-30 20:18:22 UTC (rev 358)
@@ -143,7 +143,7 @@
 	if (mysql_real_connect(mysql->mysql, hostname, username, passwd, dbname, port,
socket, CLIENT_MULTI_RESULTS) == NULL)
 #else
 	if (mysqlnd_connect(mysql->mysql, hostname, username, passwd, passwd_len, dbname,
dbname_len,
-						  port, socket, CLIENT_MULTI_RESULTS, mysqlnd_zval_cache TSRMLS_CC) == NULL)
+						  port, socket, CLIENT_MULTI_RESULTS, MyG(mysqlnd_thd_zval_cache) TSRMLS_CC) ==
NULL)
 #endif
 	{
 		/* Save error messages */

Modified: trunk/php5/ext/mysqli/php_mysqli.h
===================================================================
--- trunk/php5/ext/mysqli/php_mysqli.h	2007-04-27 20:15:15 UTC (rev 357)
+++ trunk/php5/ext/mysqli/php_mysqli.h	2007-04-30 20:18:22 UTC (rev 358)
@@ -468,6 +468,9 @@
 	HashTable		*report_ht;
 	unsigned int	multi_query;
 	unsigned int	embedded;
+#ifdef HAVE_MYSQLND
+	MYSQLND_THD_ZVAL_PCACHE	*mysqlnd_thd_zval_cache;
+#endif
 ZEND_END_MODULE_GLOBALS(mysqli)
 
 

Modified: trunk/php6/ext/mysqli/mysqli.c
===================================================================
--- trunk/php6/ext/mysqli/mysqli.c	2007-04-27 20:15:15 UTC (rev 357)
+++ trunk/php6/ext/mysqli/mysqli.c	2007-04-30 20:18:22 UTC (rev 358)
@@ -511,7 +511,7 @@
 	STD_PHP_INI_ENTRY("mysqli.default_socket",			NULL,	PHP_INI_ALL,		OnUpdateStringUnempty,	default_socket,	zend_mysqli_globals,		mysqli_globals)
 	STD_PHP_INI_BOOLEAN("mysqli.reconnect",				"0",	PHP_INI_SYSTEM,		OnUpdateLong,		reconnect,			zend_mysqli_globals,		mysqli_globals)
 #ifdef HAVE_MYSQLND
-	STD_PHP_INI_ENTRY("mysqli.cache_size",			   
"2000",	PHP_INI_SYSTEM,		OnUpdateLong,		cache_size,			zend_mysqli_globals,		mysqli_globals)
+	STD_PHP_INI_ENTRY("mysqli.cache_size",				"2000",	PHP_INI_SYSTEM,		OnUpdateLong,		cache_size,			zend_mysqli_globals,		mysqli_globals)
 #endif
 
 PHP_INI_END()
@@ -540,6 +540,7 @@
 #endif
 #ifdef HAVE_MYSQLND
 	mysqli_globals->cache_size = 0;
+	mysqli_globals->mysqlnd_thd_zval_cache = NULL;
 #endif
 }
 /* }}} */
@@ -742,7 +743,7 @@
 	zend_hash_destroy(&mysqli_link_properties);
 	zend_hash_destroy(&classes);
 #ifdef HAVE_MYSQLND
-	mysqlnd_palloc_free_cache_reference(&mysqlnd_zval_cache);
+	mysqlnd_palloc_free_cache(mysqlnd_zval_cache);
 	mysqlnd_qcache_free_cache_reference(&mysqlnd_qcache);
 	mysqlnd_library_end();
 #endif
@@ -758,7 +759,7 @@
 	MyG(error_msg) = NULL;
 	MyG(error_no) = 0;
 #ifdef HAVE_MYSQLND
-	mysqlnd_palloc_rinit(mysqlnd_zval_cache);
+	MyG(mysqlnd_thd_zval_cache) = mysqlnd_palloc_rinit(mysqlnd_zval_cache);
 #endif
 
 	return SUCCESS;
@@ -773,7 +774,7 @@
 		efree(MyG(error_msg));
 	}
 #ifdef HAVE_MYSQLND
-	mysqlnd_palloc_rshutdown(mysqlnd_zval_cache);
+	mysqlnd_palloc_rshutdown(MyG(mysqlnd_thd_zval_cache));
 #endif
 	return SUCCESS;
 }

Modified: trunk/php6/ext/mysqli/mysqli_api.c
===================================================================
--- trunk/php6/ext/mysqli/mysqli_api.c	2007-04-27 20:15:15 UTC (rev 357)
+++ trunk/php6/ext/mysqli/mysqli_api.c	2007-04-30 20:18:22 UTC (rev 358)
@@ -1653,7 +1653,7 @@
 	if (mysql_real_connect(mysql->mysql, hostname, username, passwd, dbname ,port, socket
,flags) == NULL) 
 #else
 	if (mysqlnd_connect(mysql->mysql, hostname, username, passwd, passwd_len, dbname,
dbname_len,
-						  port, socket, flags, mysqlnd_zval_cache TSRMLS_CC) == NULL)
+						  port, socket, flags, MyG(mysqlnd_thd_zval_cache) TSRMLS_CC) == NULL)
 #endif
 	{
 		php_mysqli_set_error(mysql_errno(mysql->mysql), (char *)
mysql_error(mysql->mysql) TSRMLS_CC);

Modified: trunk/php6/ext/mysqli/mysqli_nonapi.c
===================================================================
--- trunk/php6/ext/mysqli/mysqli_nonapi.c	2007-04-27 20:15:15 UTC (rev 357)
+++ trunk/php6/ext/mysqli/mysqli_nonapi.c	2007-04-30 20:18:22 UTC (rev 358)
@@ -149,7 +149,7 @@
 	if (mysql_real_connect(mysql->mysql, hostname, username, passwd, dbname, port,
socket, CLIENT_MULTI_RESULTS) == NULL)
 #else
 	if (mysqlnd_connect(mysql->mysql, hostname, username, passwd, passwd_len, dbname,
dbname_len,
-						  port, socket, CLIENT_MULTI_RESULTS, mysqlnd_zval_cache TSRMLS_CC) == NULL)
+						  port, socket, CLIENT_MULTI_RESULTS, MyG(mysqlnd_thd_zval_cache) TSRMLS_CC) ==
NULL)
 #endif
 	{
 		/* Save error messages */

Modified: trunk/php6/ext/mysqli/php_mysqli.h
===================================================================
--- trunk/php6/ext/mysqli/php_mysqli.h	2007-04-27 20:15:15 UTC (rev 357)
+++ trunk/php6/ext/mysqli/php_mysqli.h	2007-04-30 20:18:22 UTC (rev 358)
@@ -482,6 +482,9 @@
 	HashTable		*report_ht;
 	unsigned int	multi_query;
 	unsigned int	embedded;
+#ifdef HAVE_MYSQLND
+	MYSQLND_THD_ZVAL_PCACHE	*mysqlnd_thd_zval_cache;
+#endif
 ZEND_END_MODULE_GLOBALS(mysqli)
 
 

Thread
PHP mysqlnd svn commit: r358 - in trunk: mysqlnd php5/ext/mysqli php6/ext/mysqliahristov30 Apr