tony2001 Thu Oct 2 08:46:16 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/standard info.c streamsfuncs.c Log: MFH: use HashPosition to prevent race condition in multithreaded env http://cvs.php.net/viewvc.cgi/php-src/ext/standard/info.c?r1=1.249.2.10.2.14.2.11&r2=1.249.2.10.2.14.2.12&diff_format=u Index: php-src/ext/standard/info.c diff -u php-src/ext/standard/info.c:1.249.2.10.2.14.2.11 php-src/ext/standard/info.c:1.249.2.10.2.14.2.12 --- php-src/ext/standard/info.c:1.249.2.10.2.14.2.11 Wed Aug 13 00:53:28 2008 +++ php-src/ext/standard/info.c Thu Oct 2 08:46:16 2008 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: info.c,v 1.249.2.10.2.14.2.11 2008/08/13 00:53:28 jani Exp $ */ +/* $Id: info.c,v 1.249.2.10.2.14.2.12 2008/10/02 08:46:16 tony2001 Exp $ */ #include "php.h" #include "php_ini.h" @@ -528,9 +528,10 @@ ulong num_key; if ((url_stream_wrappers_hash = php_stream_get_url_stream_wrappers_hash())) { - for (zend_hash_internal_pointer_reset(url_stream_wrappers_hash); - zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, (uint *)&stream_protocol_len, &num_key, 0, NULL) == HASH_KEY_IS_STRING; - zend_hash_move_forward(url_stream_wrappers_hash)) { + HashPosition pos; + for (zend_hash_internal_pointer_reset_ex(url_stream_wrappers_hash, &pos); + zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, (uint *)&stream_protocol_len, &num_key, 0, &pos) == HASH_KEY_IS_STRING; + zend_hash_move_forward_ex(url_stream_wrappers_hash, &pos)) { stream_protocols_buf = erealloc(stream_protocols_buf, stream_protocols_buf_len + stream_protocol_len + 2 + 1); memcpy(stream_protocols_buf + stream_protocols_buf_len, stream_protocol, stream_protocol_len - 1); stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len - 1] = ','; @@ -559,9 +560,10 @@ ulong num_key; if ((stream_xport_hash = php_stream_xport_get_hash())) { - for(zend_hash_internal_pointer_reset(stream_xport_hash); - zend_hash_get_current_key_ex(stream_xport_hash, &xport_name, (uint *)&xport_name_len, &num_key, 0, NULL) == HASH_KEY_IS_STRING; - zend_hash_move_forward(stream_xport_hash)) { + HashPosition pos; + for(zend_hash_internal_pointer_reset_ex(stream_xport_hash, &pos); + zend_hash_get_current_key_ex(stream_xport_hash, &xport_name, (uint *)&xport_name_len, &num_key, 0, &pos) == HASH_KEY_IS_STRING; + zend_hash_move_forward_ex(stream_xport_hash, &pos)) { if (xport_buf_len + xport_name_len + 2 > xport_buf_size) { while (xport_buf_len + xport_name_len + 2 > xport_buf_size) { xport_buf_size += 256; @@ -600,9 +602,10 @@ ulong num_key; if ((stream_filter_hash = php_get_stream_filters_hash())) { - for(zend_hash_internal_pointer_reset(stream_filter_hash); - zend_hash_get_current_key_ex(stream_filter_hash, &filter_name, (uint *)&filter_name_len, &num_key, 0, NULL) == HASH_KEY_IS_STRING; - zend_hash_move_forward(stream_filter_hash)) { + HashPosition pos; + for(zend_hash_internal_pointer_reset_ex(stream_filter_hash, &pos); + zend_hash_get_current_key_ex(stream_filter_hash, &filter_name, (uint *)&filter_name_len, &num_key, 0, &pos) == HASH_KEY_IS_STRING; + zend_hash_move_forward_ex(stream_filter_hash, &pos)) { if (filter_buf_len + filter_name_len + 2 > filter_buf_size) { while (filter_buf_len + filter_name_len + 2 > filter_buf_size) { filter_buf_size += 256; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.58.2.6.2.15.2.21&r2=1.58.2.6.2.15.2.22&diff_format=u Index: php-src/ext/standard/streamsfuncs.c diff -u php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.15.2.21 php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.15.2.22 --- php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.15.2.21 Mon Sep 8 01:33:08 2008 +++ php-src/ext/standard/streamsfuncs.c Thu Oct 2 08:46:16 2008 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streamsfuncs.c,v 1.58.2.6.2.15.2.21 2008/09/08 01:33:08 felipe Exp $ */ +/* $Id: streamsfuncs.c,v 1.58.2.6.2.15.2.22 2008/10/02 08:46:16 tony2001 Exp $ */ #include "php.h" #include "php_globals.h" @@ -531,13 +531,14 @@ } if ((stream_xport_hash = php_stream_xport_get_hash())) { + HashPosition pos; array_init(return_value); - zend_hash_internal_pointer_reset(stream_xport_hash); + zend_hash_internal_pointer_reset_ex(stream_xport_hash, &pos); while (zend_hash_get_current_key_ex(stream_xport_hash, &stream_xport, &stream_xport_len, - &num_key, 0, NULL) == HASH_KEY_IS_STRING) { + &num_key, 0, &pos) == HASH_KEY_IS_STRING) { add_next_index_stringl(return_value, stream_xport, stream_xport_len - 1, 1); - zend_hash_move_forward(stream_xport_hash); + zend_hash_move_forward_ex(stream_xport_hash, &pos); } } else { RETURN_FALSE; @@ -559,10 +560,11 @@ } if ((url_stream_wrappers_hash = php_stream_get_url_stream_wrappers_hash())) { + HashPosition pos; array_init(return_value); - for(zend_hash_internal_pointer_reset(url_stream_wrappers_hash); - (key_flags = zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, &num_key, 0, NULL)) != HASH_KEY_NON_EXISTANT; - zend_hash_move_forward(url_stream_wrappers_hash)) { + for(zend_hash_internal_pointer_reset_ex(url_stream_wrappers_hash, &pos); + (key_flags = zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, &num_key, 0, &pos)) != HASH_KEY_NON_EXISTANT; + zend_hash_move_forward_ex(url_stream_wrappers_hash, &pos)) { if (key_flags == HASH_KEY_IS_STRING) { add_next_index_stringl(return_value, stream_protocol, stream_protocol_len - 1, 1); }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php