[PHP-CVS] svn: /php/php-src/branches/PHP_5_3/Zend/ zend_API.c zend_compile.c zend_exceptions.c zend_objects.c zend_variables.c zend_variables.h

2010-08-12 Thread Sascha Schumann
sas  Thu, 12 Aug 2010 07:58:14 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=302137

Log:
separate properties of internal classes in ZTS mode fully,
otherwise multiple threads will modify the zvals' contents
without any synchronisation.

Changed paths:
U   php/php-src/branches/PHP_5_3/Zend/zend_API.c
U   php/php-src/branches/PHP_5_3/Zend/zend_compile.c
U   php/php-src/branches/PHP_5_3/Zend/zend_exceptions.c
U   php/php-src/branches/PHP_5_3/Zend/zend_objects.c
U   php/php-src/branches/PHP_5_3/Zend/zend_variables.c
U   php/php-src/branches/PHP_5_3/Zend/zend_variables.h

Modified: php/php-src/branches/PHP_5_3/Zend/zend_API.c
===
--- php/php-src/branches/PHP_5_3/Zend/zend_API.c2010-08-12 07:36:25 UTC 
(rev 302136)
+++ php/php-src/branches/PHP_5_3/Zend/zend_API.c2010-08-12 07:58:14 UTC 
(rev 302137)
@@ -1082,7 +1082,7 @@
} else {
ALLOC_HASHTABLE_REL(object-properties);
zend_hash_init(object-properties, 
zend_hash_num_elements(class_type-default_properties), NULL, ZVAL_PTR_DTOR, 
0);
-   zend_hash_copy(object-properties, 
class_type-default_properties, (copy_ctor_func_t) zval_add_ref, (void *) 
tmp, sizeof(zval *));
+   zend_hash_copy(object-properties, 
class_type-default_properties, zval_copy_property_ctor(class_type), (void *) 
tmp, sizeof(zval *));
}
} else {
Z_OBJVAL_P(arg) = class_type-create_object(class_type 
TSRMLS_CC);

Modified: php/php-src/branches/PHP_5_3/Zend/zend_compile.c
===
--- php/php-src/branches/PHP_5_3/Zend/zend_compile.c2010-08-12 07:36:25 UTC 
(rev 302136)
+++ php/php-src/branches/PHP_5_3/Zend/zend_compile.c2010-08-12 07:58:14 UTC 
(rev 302137)
@@ -2817,26 +2817,9 @@
 }
 /* }}} */

-#ifdef ZTS
-static void zval_internal_ctor(zval **p) /* {{{ */
-{
-   zval *orig_ptr = *p;
+#define zval_property_ctor(parent_ce, ce) \
+   ((copy_ctor_func_t) (((parent_ce)-type != (ce)-type) ? 
zval_shared_property_ctor : zval_add_ref))

-   ALLOC_ZVAL(*p);
-   **p = *orig_ptr;
-   zval_copy_ctor(*p);
-   Z_SET_REFCOUNT_PP(p, 1);
-   Z_UNSET_ISREF_PP(p);
-}
-/* }}} */
-
-# define zval_property_ctor(parent_ce, ce) \
-   ((void (*)(void *)) (((parent_ce)-type != (ce)-type) ? 
zval_internal_ctor : zval_add_ref))
-#else
-# define zval_property_ctor(parent_ce, ce) \
-   ((void (*)(void *)) zval_add_ref)
-#endif
-
 ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry 
*parent_ce TSRMLS_DC) /* {{{ */
 {
if ((ce-ce_flags  ZEND_ACC_INTERFACE)

Modified: php/php-src/branches/PHP_5_3/Zend/zend_exceptions.c
===
--- php/php-src/branches/PHP_5_3/Zend/zend_exceptions.c 2010-08-12 07:36:25 UTC 
(rev 302136)
+++ php/php-src/branches/PHP_5_3/Zend/zend_exceptions.c 2010-08-12 07:58:14 UTC 
(rev 302137)
@@ -137,7 +137,7 @@

ALLOC_HASHTABLE(object-properties);
zend_hash_init(object-properties, 0, NULL, ZVAL_PTR_DTOR, 0);
-   zend_hash_copy(object-properties, class_type-default_properties, 
(copy_ctor_func_t) zval_add_ref, (void *) tmp, sizeof(zval *));
+   zend_hash_copy(object-properties, class_type-default_properties, 
zval_copy_property_ctor(class_type), (void *) tmp, sizeof(zval *));

ALLOC_ZVAL(trace);
Z_UNSET_ISREF_P(trace);

Modified: php/php-src/branches/PHP_5_3/Zend/zend_objects.c
===
--- php/php-src/branches/PHP_5_3/Zend/zend_objects.c2010-08-12 07:36:25 UTC 
(rev 302136)
+++ php/php-src/branches/PHP_5_3/Zend/zend_objects.c2010-08-12 07:58:14 UTC 
(rev 302137)
@@ -148,7 +148,7 @@

 ZEND_API void zend_objects_clone_members(zend_object *new_object, 
zend_object_value new_obj_val, zend_object *old_object, zend_object_handle 
handle TSRMLS_DC)
 {
-   zend_hash_copy(new_object-properties, old_object-properties, 
(copy_ctor_func_t) zval_add_ref, (void *) NULL /* Not used anymore */, 
sizeof(zval *));
+   zend_hash_copy(new_object-properties, old_object-properties, 
zval_copy_property_ctor(old_object-ce), (void *) NULL /* Not used anymore */, 
sizeof(zval *));

if (old_object-ce-clone) {
zval *new_obj;

Modified: php/php-src/branches/PHP_5_3/Zend/zend_variables.c
===
--- php/php-src/branches/PHP_5_3/Zend/zend_variables.c  2010-08-12 07:36:25 UTC 
(rev 302136)
+++ php/php-src/branches/PHP_5_3/Zend/zend_variables.c  2010-08-12 07:58:14 UTC 
(rev 302137)
@@ -159,7 +159,18 @@
zval_dtor(zvalue);
 }

+ZEND_API void zval_property_ctor(zval **p) /* {{{ */
+{
+   zval *orig_ptr = *p;

+   ALLOC_ZVAL(*p);
+   **p = 

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd.c branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd.c trunk/ext/mysqlnd/mysqlnd_result.c

2010-08-12 Thread Andrey Hristov
andrey   Thu, 12 Aug 2010 11:38:08 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=302141

Log:
ws + cs

Changed paths:
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c	2010-08-12 11:10:42 UTC (rev 302140)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c	2010-08-12 11:38:08 UTC (rev 302141)
@@ -550,7 +550,7 @@
 err:
 	PACKET_FREE(auth_packet);
 	PACKET_FREE(ok_packet);
-	DBG_RETURN(ret);
+	DBG_RETURN(ret);
 }
 /* }}} */

@@ -769,13 +769,13 @@
 spprintf(p, 0, %s via TCP/IP, conn-host);
 if (!p) {
 	SET_OOM_ERROR(conn-error_info);
-	goto err; /* OOM */
+	goto err; /* OOM */
 }
 conn-host_info =  mnd_pestrdup(p, conn-persistent);
 efree(p); /* allocated by spprintf */
 if (!conn-host_info) {
 	SET_OOM_ERROR(conn-error_info);
-	goto err; /* OOM */
+	goto err; /* OOM */
 }
 			}
 		} else {
@@ -783,7 +783,7 @@
 			conn-host_info		= mnd_pestrdup(Localhost via UNIX socket, conn-persistent);
 			if (!conn-unix_socket || !conn-host_info) {
 SET_OOM_ERROR(conn-error_info);
-goto err; /* OOM */
+goto err; /* OOM */
 			}
 			conn-unix_socket_len = strlen(conn-unix_socket);
 		}
@@ -1211,7 +1211,7 @@
 		/* OOM */
 		SET_OOM_ERROR(conn-error_info);
 		result-m.free_result(result, TRUE TSRMLS_CC);
-		DBG_RETURN(NULL);
+		DBG_RETURN(NULL);
 	}
 	result-unbuf-eof_reached = TRUE;

@@ -1287,8 +1287,7 @@
 PHPAPI ulong mysqlnd_old_escape_string(char *newstr, const char *escapestr, size_t escapestr_len TSRMLS_DC)
 {
 	DBG_ENTER(mysqlnd_old_escape_string);
-	DBG_RETURN(mysqlnd_cset_escape_slashes(mysqlnd_find_charset_name(latin1),
-		   newstr, escapestr, escapestr_len TSRMLS_CC));
+	DBG_RETURN(mysqlnd_cset_escape_slashes(mysqlnd_find_charset_name(latin1), newstr, escapestr, escapestr_len TSRMLS_CC));
 }
 /* }}} */

@@ -1438,8 +1437,7 @@
 		  a protocol of giving back -1. Thus we have to follow it :(
 		*/
 		SET_ERROR_AFF_ROWS(conn);
-	} else if (PASS == (ret = conn-m-simple_command(conn, COM_PROCESS_KILL, buff,
-	 4, PROT_LAST, FALSE, TRUE TSRMLS_CC))) {
+	} else if (PASS == (ret = conn-m-simple_command(conn, COM_PROCESS_KILL, buff, 4, PROT_LAST, FALSE, TRUE TSRMLS_CC))) {
 		CONN_SET_STATE(conn, CONN_QUIT_SENT);
 	}
 	DBG_RETURN(ret);
@@ -1983,7 +1981,7 @@
 PACKET_FREE(redundant_error_packet);
 DBG_INF_FMT(Server is %u, buggy, sends two ERR messages, mysqlnd_get_server_version(conn));
 			} else {
-SET_OOM_ERROR(conn-error_info);
+SET_OOM_ERROR(conn-error_info);
 			}
 		}
 	}

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c	2010-08-12 11:10:42 UTC (rev 302140)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c	2010-08-12 11:38:08 UTC (rev 302141)
@@ -205,12 +205,11 @@
 if (current_row == NULL || current_row[0] == NULL) {
 	break;/* row that was never initialized */
 }
-			mysqlnd_palloc_zval_ptr_dtor((current_row[col]), result-type, copy_ctor_called TSRMLS_CC);
+mysqlnd_palloc_zval_ptr_dtor((current_row[col]), result-type, copy_ctor_called TSRMLS_CC);
 #if MYSQLND_DEBUG_MEMORY
 DBG_INF_FMT(Copy_ctor_called=%u, copy_ctor_called);
 #endif
-MYSQLND_INC_GLOBAL_STATISTIC(copy_ctor_called? STAT_COPY_ON_WRITE_PERFORMED:
-		   STAT_COPY_ON_WRITE_SAVED);
+MYSQLND_INC_GLOBAL_STATISTIC(copy_ctor_called? STAT_COPY_ON_WRITE_PERFORMED: STAT_COPY_ON_WRITE_SAVED);
 			}
 #if MYSQLND_DEBUG_MEMORY
 			DBG_INF(Freeing current_row  current_buffer);
@@ -376,7 +375,7 @@
 		if (!rset_header) {
 			SET_OOM_ERROR(conn-error_info);
 			ret = FAIL;
-			break;
+			break;
 		}

 		SET_ERROR_AFF_ROWS(conn);
@@ -505,7 +504,7 @@
 if (!fields_eof) {
 	SET_OOM_ERROR(conn-error_info);
 	ret = FAIL;
-	break;
+	break;
 }
 if (FAIL == (ret = PACKET_READ(fields_eof, conn))) {
 	DBG_ERR(Error ocurred while reading the EOF packet);
@@ -1128,14 +1127,14 @@
 	if (!set) {
 		SET_OOM_ERROR(conn-error_info);
 		ret = FAIL;
-		goto end;
+		goto end;
 	}
 	if (free_rows) {
 		set-row_buffers = mnd_pemalloc(free_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *), to_cache);
 		if (!set-row_buffers) {
 			SET_OOM_ERROR(conn-error_info);
 			ret = FAIL;
-			goto end;
+			goto end;
 		}
 	}
 	set-persistent	= to_cache;
@@ -1277,7 +1276,7 @@
 		if (result-stored_data) {
 			conn-error_info = result-stored_data-error_info;
 		} else {
-			SET_OOM_ERROR(conn-error_info);
+			SET_OOM_ERROR(conn-error_info);
 		}
 		DBG_RETURN(NULL);
 	}
@@ -1310,9 

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd.c branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.c branches/PHP_5_3/ext/mysqlnd/mysqlnd_enum_n_def.h branches/PHP_5_3/ext/mysqlnd/mysqlnd_

2010-08-12 Thread Andrey Hristov
andrey   Thu, 12 Aug 2010 12:02:02 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=302142

Log:
Switch from using PHP_MAJOR_VERSION to separate define for
unicode. Unicode is no more, but these are bookmarks where
to change mysqlnd, if Unicode becomes trendy again.

Changed paths:
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.c
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_enum_n_def.h
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_priv.h
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_ps.c
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_ps_codec.c
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result_meta.c
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_statistics.c
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_structs.h
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/php_mysqlnd.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_debug.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_enum_n_def.h
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_priv.h
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_ps.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_ps_codec.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_result_meta.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_statistics.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_structs.h
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c
U   php/php-src/trunk/ext/mysqlnd/php_mysqlnd.c

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c	2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c	2010-08-12 12:02:02 UTC (rev 302142)
@@ -481,7 +481,7 @@
 	if (options-charset_name  (charset = mysqlnd_find_charset_name(options-charset_name))) {
 		auth_packet-charset_no	= charset-nr;
 	} else {
-#if PHP_MAJOR_VERSION = 6
+#if MYSQLND_UNICODE
 		auth_packet-charset_no	= 200;/* utf8 - swedish collation, check mysqlnd_charset.c */
 #else
 		auth_packet-charset_no	= greet_packet-charset_no;
@@ -799,7 +799,7 @@

 		mysqlnd_local_infile_default(conn);

-#if PHP_MAJOR_VERSION = 6
+#if MYSQLND_UNICODE
 		{
 			unsigned int as_unicode = 1;
 			conn-m-set_client_option(conn, MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE, (char *)as_unicode TSRMLS_CC);
@@ -2052,7 +2052,7 @@
 		case MYSQLND_OPT_NET_READ_BUFFER_SIZE:
 			ret = conn-net-m.set_client_option(conn-net, option, value TSRMLS_CC);
 			break;
-#if PHP_MAJOR_VERSION = 6
+#if MYSQLND_UNICODE
 		case MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE:
 			conn-options.numeric_and_datetime_as_unicode = *(unsigned int*) value;
 			break;

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.c
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.c	2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.c	2010-08-12 12:02:02 UTC (rev 302142)
@@ -1249,7 +1249,7 @@

 /* Follows code borrowed from zend_builtin_functions.c because the functions there are static */

-#if PHP_MAJOR_VERSION = 6
+#if MYSQLND_UNICODE
 /* {{{ gettraceasstring() macros */
 #define TRACE_APPEND_CHR(chr)\
 	*str = (char*)erealloc(*str, *len + 1 + 1);  \

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_enum_n_def.h
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_enum_n_def.h	2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_enum_n_def.h	2010-08-12 12:02:02 UTC (rev 302142)
@@ -152,7 +152,7 @@
 	MYSQL_REPORT_DATA_TRUNCATION,
 	MYSQL_OPT_RECONNECT,
 	MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
-#if PHP_MAJOR_VERSION = 6
+#if MYSQLND_UNICODE
 	MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE = 200,
 #endif
 #ifdef MYSQLND_STRING_TO_INT_CONVERSION

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_priv.h
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_priv.h	2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_priv.h	2010-08-12 12:02:02 UTC (rev 302142)
@@ -33,6 +33,12 @@
 #define Z_DELREF_PP(ppz)			Z_DELREF_P(*(ppz))
 #endif

+#if PHP_MAJOR_VERSION = 6
+#define MYSQLND_UNICODE 1
+#else
+#define MYSQLND_UNICODE 0
+#endif
+
 #ifdef ZTS
 #include TSRM.h
 #endif
@@ -45,18 +51,18 @@
 #define MYSQLND_CLASS_METHODS_START(class)	struct st_##class##_methods 

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c trunk/ext/mysqlnd/mysqlnd_wireprotocol.c

2010-08-12 Thread Andrey Hristov
andrey   Thu, 12 Aug 2010 13:23:16 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=302143

Log:
Allocate memory in a burst mode, and later use it. Increases
locality of the data.
Also use MYSQLND_INC_CONN_STATISTIC in one place, instead of
two, thus removing code duplication from macro expansion - less
code to fit in the instruction cache.

Changed paths:
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c 
2010-08-12 12:02:02 UTC (rev 302142)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c 
2010-08-12 13:23:16 UTC (rev 302143)
@@ -1201,24 +1201,29 @@

DBG_ENTER(php_mysqlnd_rowp_read_binary_protocol);

-   end_field = (current_field = start_field = fields) + field_count;
-   if (!current_field) {
+   if (!fields) {
DBG_RETURN(FAIL);
}

+   end_field = (start_field = fields) + field_count;
+
/* skip the first byte, not EODATA_MARKER - 0x0, status */
p++;
null_ptr= p;
p += (field_count + 9)/8;   /* skip null bits */
bit = 4;/* first 2 bits are 
reserved */

-   for (i = 0; current_field  end_field; current_field++, i++) {
+   for (i = 0, current_field = start_field; current_field  end_field; 
current_field++, i++) {
DBG_INF(Directly creating zval);
MAKE_STD_ZVAL(*current_field);
if (!*current_field) {
DBG_RETURN(FAIL);
}
-
+   }
+
+   for (i = 0, current_field = start_field; current_field  end_field; 
current_field++, i++) {
+   enum_mysqlnd_collected_stats statistic;
+
DBG_INF_FMT(Into zval=%p decoding column %u [%s.%s.%s] type=%u 
field-flagsunsigned=%u flags=%u is_bit=%u as_unicode=%u,
*current_field, i,
fields_metadata[i].db, fields_metadata[i].table, 
fields_metadata[i].name, fields_metadata[i].type,
@@ -1226,13 +1231,12 @@
if (*null_ptr  bit) {
DBG_INF(It's null);
ZVAL_NULL(*current_field);
-   MYSQLND_INC_CONN_STATISTIC(stats, 
STAT_BINARY_TYPE_FETCHED_NULL);
+   statistic = STAT_BINARY_TYPE_FETCHED_NULL;
} else {
enum_mysqlnd_field_types type = fields_metadata[i].type;
mysqlnd_ps_fetch_functions[type].func(*current_field, 
fields_metadata[i], 0, p, as_unicode TSRMLS_CC);

if (MYSQLND_G(collect_statistics)) {
-   enum_mysqlnd_collected_stats statistic;
switch (fields_metadata[i].type) {
case MYSQL_TYPE_DECIMAL:
statistic = STAT_BINARY_TYPE_FETCHED_DECIMAL; break;
case MYSQL_TYPE_TINY:   
statistic = STAT_BINARY_TYPE_FETCHED_INT8; break;
@@ -1263,9 +1267,10 @@
case MYSQL_TYPE_GEOMETRY:   
statistic = STAT_BINARY_TYPE_FETCHED_GEOMETRY; break;
default: statistic = 
STAT_BINARY_TYPE_FETCHED_OTHER; break;
}
-   MYSQLND_INC_CONN_STATISTIC(stats, statistic);
}
}
+   MYSQLND_INC_CONN_STATISTIC(stats, statistic);
+
if (!((bit=1)  255)) {
bit = 1;/* to the following byte */
null_ptr++;
@@ -1294,23 +1299,26 @@

DBG_ENTER(php_mysqlnd_rowp_read_text_protocol);

-   end_field = (current_field = start_field = fields) + field_count;
-   if (!current_field) {
+   if (!fields) {
DBG_RETURN(FAIL);
}

-   for (i = 0; current_field  end_field; current_field++, i++) {
-   /* Don't reverse the order. It is significant!*/
-   zend_uchar *this_field_len_pos = p;
-   /* php_mysqlnd_net_field_length() call should be after 
*this_field_len_pos = p; */
-   unsigned long len = php_mysqlnd_net_field_length(p);
+   end_field = (start_field = fields) + field_count;

+   for (i = 0, current_field = start_field; current_field  end_field; 
current_field++, i++) {
DBG_INF(Directly creating zval);
MAKE_STD_ZVAL(*current_field);
if (!*current_field) {
DBG_RETURN(FAIL);
}
+   }

+   for (i = 0, current_field = start_field; current_field  end_field; 
current_field++, i++) 

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c trunk/ext/mysqlnd/mysqlnd_result.c

2010-08-12 Thread Andrey Hristov
andrey   Thu, 12 Aug 2010 14:17:31 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=302144

Log:
Make this function static, as it is used only in this file.
Add additional comment about how it works.

Changed paths:
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c   2010-08-12 
13:23:16 UTC (rev 302143)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c   2010-08-12 
14:17:31 UTC (rev 302144)
@@ -86,12 +86,11 @@
 /* }}} */


-
 /* {{{ mysqlnd_palloc_zval_ptr_dtor */
+static
 void mysqlnd_palloc_zval_ptr_dtor(zval **zv, enum_mysqlnd_res_type type, 
zend_bool * copy_ctor_called TSRMLS_DC)
 {
DBG_ENTER(mysqlnd_palloc_zval_ptr_dtor);
-   *copy_ctor_called = FALSE;

/*
  This zval is not from the cache block.
@@ -99,6 +98,7 @@
  because the zvals from the cache are owned by it.
*/
if (type == MYSQLND_RES_PS_BUF || type == MYSQLND_RES_PS_UNBUF) {
+   *copy_ctor_called = FALSE;
; /* do nothing, zval_ptr_dtor will do the job*/
} else if (Z_REFCOUNT_PP(zv)  1) {
/*
@@ -120,6 +120,12 @@
}
*copy_ctor_called = TRUE;
} else {
+   /*
+ noone but us point to this, so we can safely ZVAL_NULL the 
zval,
+ so Zend does not try to free what the zval points to - which 
is
+ in result set buffers
+   */
+   *copy_ctor_called = FALSE;
if (Z_TYPE_PP(zv) == IS_STRING) {
ZVAL_NULL(*zv);
}

Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c
===
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c  2010-08-12 13:23:16 UTC 
(rev 302143)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c  2010-08-12 14:17:31 UTC 
(rev 302144)
@@ -86,12 +86,11 @@
 /* }}} */


-
 /* {{{ mysqlnd_palloc_zval_ptr_dtor */
+static
 void mysqlnd_palloc_zval_ptr_dtor(zval **zv, enum_mysqlnd_res_type type, 
zend_bool * copy_ctor_called TSRMLS_DC)
 {
DBG_ENTER(mysqlnd_palloc_zval_ptr_dtor);
-   *copy_ctor_called = FALSE;

/*
  This zval is not from the cache block.
@@ -99,6 +98,7 @@
  because the zvals from the cache are owned by it.
*/
if (type == MYSQLND_RES_PS_BUF || type == MYSQLND_RES_PS_UNBUF) {
+   *copy_ctor_called = FALSE;
; /* do nothing, zval_ptr_dtor will do the job*/
} else if (Z_REFCOUNT_PP(zv)  1) {
/*
@@ -120,6 +120,12 @@
}
*copy_ctor_called = TRUE;
} else {
+   /*
+ noone but us point to this, so we can safely ZVAL_NULL the 
zval,
+ so Zend does not try to free what the zval points to - which 
is
+ in result set buffers
+   */
+   *copy_ctor_called = FALSE;
if (Z_TYPE_PP(zv) == IS_STRING) {
ZVAL_NULL(*zv);
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/branches/PHP_5_2/Zend/ zend_API.c zend_compile.c zend_exceptions.c zend_objects.c zend_variables.c zend_variables.h

2010-08-12 Thread Sascha Schumann
sas  Thu, 12 Aug 2010 17:27:16 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=302150

Log:
separate properties of internal classes in ZTS mode fully,
otherwise multiple threads will modify the zvals' contents
without any synchronisation.

Changed paths:
U   php/php-src/branches/PHP_5_2/Zend/zend_API.c
U   php/php-src/branches/PHP_5_2/Zend/zend_compile.c
U   php/php-src/branches/PHP_5_2/Zend/zend_exceptions.c
U   php/php-src/branches/PHP_5_2/Zend/zend_objects.c
U   php/php-src/branches/PHP_5_2/Zend/zend_variables.c
U   php/php-src/branches/PHP_5_2/Zend/zend_variables.h

Modified: php/php-src/branches/PHP_5_2/Zend/zend_API.c
===
--- php/php-src/branches/PHP_5_2/Zend/zend_API.c2010-08-12 16:00:19 UTC 
(rev 302149)
+++ php/php-src/branches/PHP_5_2/Zend/zend_API.c2010-08-12 17:27:16 UTC 
(rev 302150)
@@ -952,7 +952,7 @@
} else {
ALLOC_HASHTABLE_REL(object-properties);
zend_hash_init(object-properties, 
zend_hash_num_elements(class_type-default_properties), NULL, ZVAL_PTR_DTOR, 
0);
-   zend_hash_copy(object-properties, 
class_type-default_properties, (copy_ctor_func_t) zval_add_ref, (void *) 
tmp, sizeof(zval *));
+   zend_hash_copy(object-properties, 
class_type-default_properties, zval_copy_property_ctor(class_type), (void *) 
tmp, sizeof(zval *));
}
} else {
Z_OBJVAL_P(arg) = class_type-create_object(class_type 
TSRMLS_CC);

Modified: php/php-src/branches/PHP_5_2/Zend/zend_compile.c
===
--- php/php-src/branches/PHP_5_2/Zend/zend_compile.c2010-08-12 16:00:19 UTC 
(rev 302149)
+++ php/php-src/branches/PHP_5_2/Zend/zend_compile.c2010-08-12 17:27:16 UTC 
(rev 302150)
@@ -2298,25 +2298,9 @@
return ZEND_HASH_APPLY_KEEP;
 }

-#ifdef ZTS
-static void zval_internal_ctor(zval **p)
-{
-   zval *orig_ptr = *p;
+#define zval_property_ctor(parent_ce, ce) \
+   ((copy_ctor_func_t) (((parent_ce)-type != (ce)-type) ? 
zval_shared_property_ctor : zval_add_ref))

-   ALLOC_ZVAL(*p);
-   **p = *orig_ptr;
-   zval_copy_ctor(*p);
-   (*p)-refcount = 1;
-   (*p)-is_ref = 0;
-}
-
-# define zval_property_ctor(parent_ce, ce) \
-   ((void (*)(void *)) (((parent_ce)-type != (ce)-type) ? 
zval_internal_ctor : zval_add_ref))
-#else
-# define zval_property_ctor(parent_ce, ce) \
-   ((void (*)(void *)) zval_add_ref)
-#endif
-
 ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry 
*parent_ce TSRMLS_DC)
 {
if ((ce-ce_flags  ZEND_ACC_INTERFACE)

Modified: php/php-src/branches/PHP_5_2/Zend/zend_exceptions.c
===
--- php/php-src/branches/PHP_5_2/Zend/zend_exceptions.c 2010-08-12 16:00:19 UTC 
(rev 302149)
+++ php/php-src/branches/PHP_5_2/Zend/zend_exceptions.c 2010-08-12 17:27:16 UTC 
(rev 302150)
@@ -84,7 +84,7 @@

ALLOC_HASHTABLE(object-properties);
zend_hash_init(object-properties, 0, NULL, ZVAL_PTR_DTOR, 0);
-   zend_hash_copy(object-properties, class_type-default_properties, 
(copy_ctor_func_t) zval_add_ref, (void *) tmp, sizeof(zval *));
+   zend_hash_copy(object-properties, class_type-default_properties, 
zval_copy_property_ctor(class_type), (void *) tmp, sizeof(zval *));

ALLOC_ZVAL(trace);
trace-is_ref = 0;

Modified: php/php-src/branches/PHP_5_2/Zend/zend_objects.c
===
--- php/php-src/branches/PHP_5_2/Zend/zend_objects.c2010-08-12 16:00:19 UTC 
(rev 302149)
+++ php/php-src/branches/PHP_5_2/Zend/zend_objects.c2010-08-12 17:27:16 UTC 
(rev 302150)
@@ -156,7 +156,7 @@
(*p)-value.obj = Z_OBJ_HT_PP(p)-clone_obj(orig 
TSRMLS_CC);
}
} else {
-   (*p)-refcount++;
+   zval_shared_property_ctor(p);
}
 }

@@ -165,7 +165,7 @@
if (EG(ze1_compatibility_mode)) {
zend_hash_copy(new_object-properties, old_object-properties, 
(copy_ctor_func_t) zval_add_ref_or_clone, (void *) NULL /* Not used anymore */, 
sizeof(zval *));
} else {
-   zend_hash_copy(new_object-properties, old_object-properties, 
(copy_ctor_func_t) zval_add_ref, (void *) NULL /* Not used anymore */, 
sizeof(zval *));
+   zend_hash_copy(new_object-properties, old_object-properties, 
zval_copy_property_ctor(old_object-ce), (void *) NULL /* Not used anymore */, 
sizeof(zval *));
}
if (old_object-ce-clone) {
zval *new_obj;

Modified: php/php-src/branches/PHP_5_2/Zend/zend_variables.c
===
--- php/php-src/branches/PHP_5_2/Zend/zend_variables.c  2010-08-12