Ticket #208: constant.diff
| File constant.diff, 4.6 KB (added by moo, 5 years ago) |
|---|
-
utils.c
594 594 /* }}} */ 595 595 #endif 596 596 597 static void xc_copy_zend_constant(zend_constant *c) /* {{{ */ 598 { 599 c->name = zend_strndup(c->name, c->name_len - 1); 600 if (!(c->flags & CONST_PERSISTENT)) { 601 zval_copy_ctor(&c->value); 602 } 603 } 604 /* }}} */ 597 605 xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /* {{{ */ 598 606 { 599 607 HashTable *h; … … 631 639 #ifdef HAVE_XCACHE_CONSTANT 632 640 h = OG(zend_constants); 633 641 zend_hash_init_ex(&TG(zend_constants), 20, NULL, h->pDestructor, h->persistent, h->bApplyProtection); 642 { 643 zend_constant tmp_const; 644 zend_hash_copy(&TG(zend_constants), &XG(internal_constant_table), (copy_ctor_func_t) xc_copy_zend_constant, (void *) &tmp_const, sizeof(tmp_const)); 645 } 634 646 #endif 635 647 h = OG(function_table); 636 648 zend_hash_init_ex(&TG(function_table), 128, NULL, h->pDestructor, h->persistent, h->bApplyProtection); … … 678 690 sandbox->orig_compiler_options = CG(compiler_options); 679 691 /* Using ZEND_COMPILE_IGNORE_INTERNAL_CLASSES for ZEND_FETCH_CLASS_RT_NS_CHECK 680 692 */ 681 CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES | ZEND_COMPILE_ DELAYED_BINDING;693 CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES | ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION | ZEND_COMPILE_DELAYED_BINDING; 682 694 #endif 683 695 684 696 XG(sandbox) = (void *) sandbox; … … 697 709 Bucket *b; 698 710 699 711 #ifdef HAVE_XCACHE_CONSTANT 700 b = TG(zend_constants).pListHead;712 b = /*TG(internal_constant_tail) ? TG(internal_constant_tail)->pListNext :*/ TG(zend_constants).pListHead; 701 713 /* install constants */ 702 714 while (b != NULL) { 703 715 zend_constant *c = (zend_constant*) b->pData; -
utils.h
94 94 HashTable tmp_function_table; 95 95 HashTable tmp_class_table; 96 96 HashTable tmp_auto_globals; 97 #ifdef HAVE_XCACHE_CONSTANT 98 Bucket *tmp_internal_constant_tail; 99 #endif 97 100 Bucket *tmp_internal_function_tail; 98 101 Bucket *tmp_internal_class_tail; 99 102 -
xcache_globals.h
21 21 HashTable gc_op_arrays; 22 22 #endif 23 23 24 #ifdef HAVE_XCACHE_CONSTANT 25 HashTable internal_constant_table; 26 #endif 24 27 HashTable internal_function_table; 25 28 HashTable internal_class_table; 26 29 zend_bool internal_table_copied; -
xcache.c
1848 1848 return 0; 1849 1849 } 1850 1850 /* }}} */ 1851 static void xc_copy_zend_constant(zend_constant *c) /* {{{ */ 1852 { 1853 c->name = zend_strndup(c->name, c->name_len - 1); 1854 if (!(c->flags & CONST_PERSISTENT)) { 1855 zval_copy_ctor(&c->value); 1856 } 1857 } 1858 /* }}} */ 1851 1859 static void xc_request_init(TSRMLS_D) /* {{{ */ 1852 1860 { 1853 1861 int i; 1854 1862 1855 1863 if (!XG(internal_table_copied)) { 1864 #ifdef HAVE_XCACHE_CONSTANT 1865 zend_constant tmp_const; 1866 #endif 1856 1867 zend_function tmp_func; 1857 1868 xc_cest_t tmp_cest; 1858 1869 1870 #ifdef HAVE_XCACHE_CONSTANT 1871 zend_hash_destroy(&XG(internal_constant_table)); 1872 #endif 1859 1873 zend_hash_destroy(&XG(internal_function_table)); 1860 1874 zend_hash_destroy(&XG(internal_class_table)); 1861 1875 1876 #ifdef HAVE_XCACHE_CONSTANT 1877 zend_hash_init_ex(&XG(internal_constant_table), 20, NULL, NULL, 1, 0); 1878 #endif 1862 1879 zend_hash_init_ex(&XG(internal_function_table), 100, NULL, NULL, 1, 0); 1863 1880 zend_hash_init_ex(&XG(internal_class_table), 10, NULL, NULL, 1, 0); 1864 1881 1882 #ifdef HAVE_XCACHE_CONSTANT 1883 zend_hash_copy(&XG(internal_constant_table), EG(zend_constants), (copy_ctor_func_t) xc_copy_zend_constant, &tmp_const, sizeof(tmp_const)); 1884 #endif 1865 1885 zend_hash_copy(&XG(internal_function_table), CG(function_table), NULL, &tmp_func, sizeof(tmp_func)); 1866 1886 zend_hash_copy(&XG(internal_class_table), CG(class_table), NULL, &tmp_cest, sizeof(tmp_cest)); 1867 1887 … … 1920 1940 { 1921 1941 memset(xcache_globals, 0, sizeof(zend_xcache_globals)); 1922 1942 1943 #ifdef HAVE_XCACHE_CONSTANT 1944 zend_hash_init_ex(&xcache_globals->internal_constant_table, 1, NULL, NULL, 1, 0); 1945 #endif 1923 1946 zend_hash_init_ex(&xcache_globals->internal_function_table, 1, NULL, NULL, 1, 0); 1924 1947 zend_hash_init_ex(&xcache_globals->internal_class_table, 1, NULL, NULL, 1, 0); 1925 1948 } … … 1951 1974 } 1952 1975 1953 1976 if (xcache_globals->internal_table_copied) { 1977 #ifdef HAVE_XCACHE_CONSTANT 1978 zend_hash_destroy(&xcache_globals->internal_constant_table); 1979 #endif 1954 1980 zend_hash_destroy(&xcache_globals->internal_function_table); 1955 1981 zend_hash_destroy(&xcache_globals->internal_class_table); 1956 1982 }

