@@ -548,6 +548,33 @@ void pthreads_prepare(PTHREAD thread TSRMLS_DC){
548548 );
549549 }
550550
551+ /* inherit globals */
552+ if (thread -> options & PTHREADS_ALLOW_GLOBALS ) {
553+ HashPosition position ;
554+ HashTable * tables [] = {& PTHREADS_EG (thread -> cls , symbol_table ), & EG (symbol_table )};
555+ zval * * symbol = NULL ;
556+
557+ for (zend_hash_internal_pointer_reset_ex (tables [0 ], & position );
558+ zend_hash_get_current_data_ex (tables [0 ], (void * * ) & symbol , & position ) == SUCCESS ;
559+ zend_hash_move_forward_ex (tables [0 ], & position )) {
560+ char * symname = NULL ;
561+ int symlen = 0 ;
562+ zend_ulong symidx = 0L ;
563+
564+ if (zend_hash_get_current_key_ex (tables [0 ], & symname , & symlen , & symidx , 0 , & position ) == HASH_KEY_IS_STRING ) {
565+ zval * separated = NULL ;
566+
567+ if (pthreads_store_separate_from (* symbol , & separated , 1 , 1 , thread -> cls TSRMLS_CC ) == SUCCESS ) {
568+ Z_SET_REFCOUNT_P (separated , 1 );
569+ Z_SET_ISREF_P (separated );
570+ zend_hash_update (tables [1 ], symname , symlen , (void * * ) & separated , sizeof (zval * ), NULL );
571+ } else {
572+ zval_ptr_dtor (& separated );
573+ }
574+ }
575+ }
576+ }
577+
551578 /* set sensible resource destructor */
552579 if (!PTHREADS_G (default_resource_dtor ))
553580 PTHREADS_G (default_resource_dtor )= (EG (regular_list ).pDestructor );
0 commit comments