tony2001                Thu Oct  2 08:46:04 2008 UTC

  Modified files:              
    /php-src/ext/standard       info.c streamsfuncs.c 
  Log:
  use HashPosition to prevent race condition in multithreaded env
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/info.c?r1=1.292&r2=1.293&diff_format=u
Index: php-src/ext/standard/info.c
diff -u php-src/ext/standard/info.c:1.292 php-src/ext/standard/info.c:1.293
--- php-src/ext/standard/info.c:1.292   Wed Aug 13 00:49:59 2008
+++ php-src/ext/standard/info.c Thu Oct  2 08:46:04 2008
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: info.c,v 1.292 2008/08/13 00:49:59 jani Exp $ */
+/* $Id: info.c,v 1.293 2008/10/02 08:46:04 tony2001 Exp $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -139,14 +139,16 @@
        
        if (ht) {
                if (zend_hash_num_elements(ht)) {
+                       HashPosition pos;
+
                        if (!sapi_module.phpinfo_as_text) {
                                php_info_printf("<tr class=\"v\"><td>Registered 
%s</td><td>", name);
                        } else {
                                php_info_printf("\nRegistered %s => ", name);
                        }
                        
-                       zend_hash_internal_pointer_reset(ht);
-                       type = zend_hash_get_current_key_ex(ht, &key, &len, 
NULL, 0, NULL);
+                       zend_hash_internal_pointer_reset_ex(ht, &pos);
+                       type = zend_hash_get_current_key_ex(ht, &key, &len, 
NULL, 0, &pos);
                        do {
                                switch (type) {
                                        case IS_STRING:
@@ -157,8 +159,8 @@
                                                break;
                                }
                                
-                               zend_hash_move_forward(ht);
-                               type = zend_hash_get_current_key_ex(ht, &key, 
&len, NULL, 0, NULL);
+                               zend_hash_move_forward_ex(ht, &pos);
+                               type = zend_hash_get_current_key_ex(ht, &key, 
&len, NULL, 0, &pos);
                                
                                if (type == IS_STRING || type == IS_UNICODE) {
                                        php_info_print(", ");
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.122&r2=1.123&diff_format=u
Index: php-src/ext/standard/streamsfuncs.c
diff -u php-src/ext/standard/streamsfuncs.c:1.122 
php-src/ext/standard/streamsfuncs.c:1.123
--- php-src/ext/standard/streamsfuncs.c:1.122   Mon Sep  8 01:30:55 2008
+++ php-src/ext/standard/streamsfuncs.c Thu Oct  2 08:46:04 2008
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: streamsfuncs.c,v 1.122 2008/09/08 01:30:55 felipe Exp $ */
+/* $Id: streamsfuncs.c,v 1.123 2008/10/02 08:46:04 tony2001 Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -573,13 +573,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_rt_stringl(return_value, stream_xport.s, 
stream_xport_len - 1, ZSTR_DUPLICATE);
-                       zend_hash_move_forward(stream_xport_hash);
+                       zend_hash_move_forward_ex(stream_xport_hash, &pos);
                }
        } else {
                RETURN_FALSE;
@@ -601,10 +602,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_rt_stringl(return_value, 
stream_protocol.s, stream_protocol_len - 1, ZSTR_DUPLICATE);
                                }



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

Reply via email to