|
36 | 36 | #include "main/php_open_temporary_file.h"
|
37 | 37 | #include "zend_API.h"
|
38 | 38 | #include "zend_ini.h"
|
39 |
| -#include "zend_virtual_cwd.h" |
| 39 | +#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO |
| 40 | +# include "zend_virtual_cwd.h" |
| 41 | +#else |
| 42 | +# include "TSRM/tsrm_virtual_cwd.h" |
| 43 | +#endif |
40 | 44 | #include "zend_accelerator_util_funcs.h"
|
41 | 45 | #include "zend_accelerator_hash.h"
|
42 | 46 |
|
@@ -387,8 +391,10 @@ static void accel_use_shm_interned_strings(TSRMLS_D)
|
387 | 391 | {
|
388 | 392 | Bucket *p, *q;
|
389 | 393 |
|
| 394 | +#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO |
390 | 395 | /* empty string */
|
391 | 396 | CG(interned_empty_string) = accel_new_interned_string("", sizeof(""), 0 TSRMLS_CC);
|
| 397 | +#endif |
392 | 398 |
|
393 | 399 | /* function table hash keys */
|
394 | 400 | p = CG(function_table)->pListHead;
|
@@ -2135,7 +2141,9 @@ static void accel_activate(void)
|
2135 | 2141 | }
|
2136 | 2142 |
|
2137 | 2143 | #if (ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO) && !defined(ZTS)
|
2138 |
| - accel_interned_strings_restore_state(TSRMLS_C); |
| 2144 | + if (ZCG(accel_directives).interned_strings_buffer) { |
| 2145 | + accel_interned_strings_restore_state(TSRMLS_C); |
| 2146 | + } |
2139 | 2147 | #endif
|
2140 | 2148 |
|
2141 | 2149 | zend_shared_alloc_restore_state();
|
@@ -2453,36 +2461,39 @@ static int zend_accel_init_shm(TSRMLS_D)
|
2453 | 2461 |
|
2454 | 2462 | #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
|
2455 | 2463 |
|
| 2464 | + ZCSG(interned_strings_start) = ZCSG(interned_strings_end) = NULL; |
2456 | 2465 | # ifndef ZTS
|
2457 | 2466 | zend_hash_init(&ZCSG(interned_strings), (ZCG(accel_directives).interned_strings_buffer * 1024 * 1024) / (sizeof(Bucket) + sizeof(Bucket*) + 8 /* average string length */), NULL, NULL, 1);
|
2458 |
| - ZCSG(interned_strings).nTableMask = ZCSG(interned_strings).nTableSize - 1; |
2459 |
| - ZCSG(interned_strings).arBuckets = zend_shared_alloc(ZCSG(interned_strings).nTableSize * sizeof(Bucket *)); |
2460 |
| - ZCSG(interned_strings_start) = zend_shared_alloc((ZCG(accel_directives).interned_strings_buffer * 1024 * 1024)); |
2461 |
| - if (!ZCSG(interned_strings).arBuckets || !ZCSG(interned_strings_start)) { |
2462 |
| - zend_accel_error(ACCEL_LOG_FATAL, ACCELERATOR_PRODUCT_NAME " cannot allocate buffer for interned strings"); |
2463 |
| - return FAILURE; |
| 2467 | + if (ZCG(accel_directives).interned_strings_buffer) { |
| 2468 | + ZCSG(interned_strings).nTableMask = ZCSG(interned_strings).nTableSize - 1; |
| 2469 | + ZCSG(interned_strings).arBuckets = zend_shared_alloc(ZCSG(interned_strings).nTableSize * sizeof(Bucket *)); |
| 2470 | + ZCSG(interned_strings_start) = zend_shared_alloc((ZCG(accel_directives).interned_strings_buffer * 1024 * 1024)); |
| 2471 | + if (!ZCSG(interned_strings).arBuckets || !ZCSG(interned_strings_start)) { |
| 2472 | + zend_accel_error(ACCEL_LOG_FATAL, ACCELERATOR_PRODUCT_NAME " cannot allocate buffer for interned strings"); |
| 2473 | + return FAILURE; |
| 2474 | + } |
| 2475 | + ZCSG(interned_strings_end) = ZCSG(interned_strings_start) + (ZCG(accel_directives).interned_strings_buffer * 1024 * 1024); |
| 2476 | + ZCSG(interned_strings_top) = ZCSG(interned_strings_start); |
| 2477 | + |
| 2478 | + orig_interned_strings_start = CG(interned_strings_start); |
| 2479 | + orig_interned_strings_end = CG(interned_strings_end); |
| 2480 | + CG(interned_strings_start) = ZCSG(interned_strings_start); |
| 2481 | + CG(interned_strings_end) = ZCSG(interned_strings_end); |
2464 | 2482 | }
|
2465 |
| - ZCSG(interned_strings_end) = ZCSG(interned_strings_start) + (ZCG(accel_directives).interned_strings_buffer * 1024 * 1024); |
2466 |
| - ZCSG(interned_strings_top) = ZCSG(interned_strings_start); |
2467 |
| -# else |
2468 |
| - ZCSG(interned_strings_start) = ZCSG(interned_strings_end) = NULL; |
2469 | 2483 | # endif
|
2470 | 2484 |
|
2471 |
| - orig_interned_strings_start = CG(interned_strings_start); |
2472 |
| - orig_interned_strings_end = CG(interned_strings_end); |
2473 | 2485 | orig_new_interned_string = zend_new_interned_string;
|
2474 | 2486 | orig_interned_strings_snapshot = zend_interned_strings_snapshot;
|
2475 | 2487 | orig_interned_strings_restore = zend_interned_strings_restore;
|
2476 |
| - |
2477 |
| - CG(interned_strings_start) = ZCSG(interned_strings_start); |
2478 |
| - CG(interned_strings_end) = ZCSG(interned_strings_end); |
2479 | 2488 | zend_new_interned_string = accel_new_interned_string_for_php;
|
2480 | 2489 | zend_interned_strings_snapshot = accel_interned_strings_snapshot_for_php;
|
2481 | 2490 | zend_interned_strings_restore = accel_interned_strings_restore_for_php;
|
2482 | 2491 |
|
2483 | 2492 | # ifndef ZTS
|
2484 |
| - accel_use_shm_interned_strings(TSRMLS_C); |
2485 |
| - accel_interned_strings_save_state(TSRMLS_C); |
| 2493 | + if (ZCG(accel_directives).interned_strings_buffer) { |
| 2494 | + accel_use_shm_interned_strings(TSRMLS_C); |
| 2495 | + accel_interned_strings_save_state(TSRMLS_C); |
| 2496 | + } |
2486 | 2497 | # endif
|
2487 | 2498 |
|
2488 | 2499 | #endif
|
@@ -2711,27 +2722,28 @@ void accel_shutdown(TSRMLS_D)
|
2711 | 2722 | return;
|
2712 | 2723 | }
|
2713 | 2724 |
|
2714 |
| - accel_free_ts_resources(); |
2715 |
| - zend_shared_alloc_shutdown(); |
2716 |
| - zend_compile_file = accelerator_orig_compile_file; |
2717 |
| - |
2718 |
| - if (zend_hash_find(EG(ini_directives), "include_path", sizeof("include_path"), (void **) &ini_entry) == SUCCESS) { |
2719 |
| - ini_entry->on_modify = orig_include_path_on_modify; |
2720 |
| - } |
2721 |
| - |
2722 | 2725 | #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
|
| 2726 | + if (ZCG(accel_directives).interned_strings_buffer) { |
2723 | 2727 | # ifndef ZTS
|
2724 |
| - zend_hash_clean(CG(function_table)); |
2725 |
| - zend_hash_clean(CG(class_table)); |
2726 |
| - zend_hash_clean(EG(zend_constants)); |
| 2728 | + zend_hash_clean(CG(function_table)); |
| 2729 | + zend_hash_clean(CG(class_table)); |
| 2730 | + zend_hash_clean(EG(zend_constants)); |
2727 | 2731 | # endif
|
2728 |
| - CG(interned_strings_start) = orig_interned_strings_start; |
2729 |
| - CG(interned_strings_end) = orig_interned_strings_end; |
| 2732 | + CG(interned_strings_start) = orig_interned_strings_start; |
| 2733 | + CG(interned_strings_end) = orig_interned_strings_end; |
| 2734 | + } |
2730 | 2735 | zend_new_interned_string = orig_new_interned_string;
|
2731 | 2736 | zend_interned_strings_snapshot = orig_interned_strings_snapshot;
|
2732 | 2737 | zend_interned_strings_restore = orig_interned_strings_restore;
|
2733 | 2738 | #endif
|
2734 | 2739 |
|
| 2740 | + accel_free_ts_resources(); |
| 2741 | + zend_shared_alloc_shutdown(); |
| 2742 | + zend_compile_file = accelerator_orig_compile_file; |
| 2743 | + |
| 2744 | + if (zend_hash_find(EG(ini_directives), "include_path", sizeof("include_path"), (void **) &ini_entry) == SUCCESS) { |
| 2745 | + ini_entry->on_modify = orig_include_path_on_modify; |
| 2746 | + } |
2735 | 2747 | }
|
2736 | 2748 |
|
2737 | 2749 | void zend_accel_schedule_restart(zend_accel_restart_reason reason TSRMLS_DC)
|
|
0 commit comments