@@ -533,7 +533,7 @@ static void zend_accel_function_hash_copy_from_shm(HashTable *target, HashTable
533
533
goto failure ;
534
534
}
535
535
} else {
536
- _zend_hash_append_ptr (target , p -> key , ARENA_REALLOC (Z_PTR (p -> val )));
536
+ _zend_hash_append_ptr_ex (target , p -> key , ARENA_REALLOC (Z_PTR (p -> val )), 1 );
537
537
}
538
538
}
539
539
target -> nInternalPointer = 0 ;
@@ -556,7 +556,7 @@ static void zend_accel_function_hash_copy_from_shm(HashTable *target, HashTable
556
556
}
557
557
}
558
558
559
- static void zend_accel_class_hash_copy (HashTable * target , HashTable * source , unique_copy_ctor_func_t pCopyConstructor )
559
+ static void zend_accel_class_hash_copy (HashTable * target , HashTable * source )
560
560
{
561
561
Bucket * p , * end ;
562
562
zval * t ;
@@ -587,9 +587,44 @@ static void zend_accel_class_hash_copy(HashTable *target, HashTable *source, uni
587
587
}
588
588
} else {
589
589
t = _zend_hash_append_ptr (target , p -> key , Z_PTR (p -> val ));
590
- if (pCopyConstructor ) {
591
- pCopyConstructor (& Z_PTR_P (t ));
590
+ }
591
+ }
592
+ target -> nInternalPointer = 0 ;
593
+ return ;
594
+ }
595
+
596
+ static void zend_accel_class_hash_copy_from_shm (HashTable * target , HashTable * source )
597
+ {
598
+ Bucket * p , * end ;
599
+ zval * t ;
600
+
601
+ zend_hash_extend (target , target -> nNumUsed + source -> nNumUsed , 0 );
602
+ p = source -> arData ;
603
+ end = p + source -> nNumUsed ;
604
+ for (; p != end ; p ++ ) {
605
+ ZEND_ASSERT (Z_TYPE (p -> val ) != IS_UNDEF );
606
+ ZEND_ASSERT (p -> key );
607
+ t = zend_hash_find_ex (target , p -> key , 1 );
608
+ if (UNEXPECTED (t != NULL )) {
609
+ if (EXPECTED (ZSTR_LEN (p -> key ) > 0 ) && EXPECTED (ZSTR_VAL (p -> key )[0 ] == 0 )) {
610
+ /* Mangled key - ignore and wait for runtime */
611
+ continue ;
612
+ } else if (UNEXPECTED (!ZCG (accel_directives ).ignore_dups )) {
613
+ zend_class_entry * ce1 = Z_PTR (p -> val );
614
+ if (!(ce1 -> ce_flags & ZEND_ACC_ANON_CLASS )) {
615
+ CG (in_compilation ) = 1 ;
616
+ zend_set_compiled_filename (ce1 -> info .user .filename );
617
+ CG (zend_lineno ) = ce1 -> info .user .line_start ;
618
+ zend_error (E_ERROR ,
619
+ "Cannot declare %s %s, because the name is already in use" ,
620
+ zend_get_object_type (ce1 ), ZSTR_VAL (ce1 -> name ));
621
+ return ;
622
+ }
623
+ continue ;
592
624
}
625
+ } else {
626
+ t = _zend_hash_append_ptr_ex (target , p -> key , Z_PTR (p -> val ), 1 );
627
+ zend_class_copy_ctor ((zend_class_entry * * )& Z_PTR_P (t ));
593
628
}
594
629
}
595
630
target -> nInternalPointer = 0 ;
@@ -771,7 +806,7 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script,
771
806
772
807
/* Copy all the necessary stuff from shared memory to regular memory, and protect the shared script */
773
808
if (zend_hash_num_elements (& persistent_script -> script .class_table ) > 0 ) {
774
- zend_accel_class_hash_copy (CG (class_table ), & persistent_script -> script .class_table , ( unique_copy_ctor_func_t ) zend_class_copy_ctor );
809
+ zend_accel_class_hash_copy_from_shm (CG (class_table ), & persistent_script -> script .class_table );
775
810
}
776
811
/* we must first to copy all classes and then prepare functions, since functions may try to bind
777
812
classes - which depend on pre-bind class entries existent in the class table */
@@ -799,7 +834,7 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script,
799
834
zend_accel_function_hash_copy (CG (function_table ), & persistent_script -> script .function_table );
800
835
}
801
836
if (zend_hash_num_elements (& persistent_script -> script .class_table ) > 0 ) {
802
- zend_accel_class_hash_copy (CG (class_table ), & persistent_script -> script .class_table , NULL );
837
+ zend_accel_class_hash_copy (CG (class_table ), & persistent_script -> script .class_table );
803
838
}
804
839
}
805
840
0 commit comments