Changeset 1064
- Timestamp:
- 2012-07-27T18:37:37+02:00 (11 months ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
ChangeLog (modified) (1 diff)
-
NEWS (modified) (1 diff)
-
htdocs/cacher/cacher-zh-simplified.lang.php (modified) (1 diff)
-
htdocs/cacher/cacher-zh-traditional.lang.php (modified) (1 diff)
-
htdocs/cacher/cacher.php (modified) (3 diffs)
-
htdocs/cacher/cacher.tpl.php (modified) (4 diffs)
-
mod_cacher/xc_cacher.c (modified) (28 diffs)
-
mod_cacher/xc_cacher.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r1039 r1064 3 3 ======== 4 4 * chg: proto array xcache_clear_cache(int type, [ int id = -1 ]). -1 means all cache splits 5 * new: proto array xcache_enable_cache(int type, [ int id = -1, [ bool enable = true ] ]) 5 6 6 7 Ini Settings Changes -
trunk/NEWS
r1039 r1064 4 4 * adds warning for misconfiguration 5 5 * auto disable caching on crash 6 * updated api 6 7 * uses extension to load XCache. load via zend_extension is unsupported 7 8 * updated XCache admin page -
trunk/htdocs/cacher/cacher-zh-simplified.lang.php
r1063 r1064 18 18 'Normal' 19 19 => '正常', 20 'Compiling(%s)' 21 => '编译中(%s)', 20 'Compiling' 21 => '编译中', 22 'Disabled' 23 => '禁用', 24 'Disable' 25 => '禁用', 26 'Enable' 27 => '启用', 22 28 'Modify' 23 29 => '修改', -
trunk/htdocs/cacher/cacher-zh-traditional.lang.php
r1063 r1064 18 18 'Normal' 19 19 => '正常', 20 'Compiling(%s)' 21 => '編譯中(%s)', 20 'Compiling' 21 => '編譯中', 22 'Disabled' 23 => '禁用', 24 'Disable' 25 => '禁用', 26 'Enable' 27 => '啟用', 22 28 'Modify' 23 29 => '修改', -
trunk/htdocs/cacher/cacher.php
r1058 r1064 158 158 $_GET['type'] = $type = (int) $_GET['type']; 159 159 160 // {{{ process clear 161 function process Clear()160 // {{{ process clear, enable, disable 161 function processAction() 162 162 { 163 163 $type = isset($_POST['type']) ? $_POST['type'] : null; … … 168 168 $cacheid = (int) (isset($_POST['cacheid']) ? $_POST['cacheid'] : 0); 169 169 if (isset($_POST['clearcache'])) { 170 $count = xcache_count($type); 171 if ($cacheid >= 0) { 172 for ($cacheid = 0; $cacheid < $count; $cacheid ++) { 173 xcache_clear_cache($type, $cacheid); 174 } 175 } 176 else { 177 xcache_clear_cache($type); 178 } 179 } 180 } 181 } 182 processClear(); 170 xcache_clear_cache($type, $cacheid); 171 } 172 if (isset($_POST['enable'])) { 173 xcache_enable_cache($type, $cacheid); 174 } 175 if (isset($_POST['disable'])) { 176 xcache_enable_cache($type, $cacheid, false); 177 } 178 } 179 } 180 processAction(); 183 181 // }}} 184 182 // {{{ load info/list … … 207 205 $total['gc'] = null; 208 206 $total['istotal'] = true; 207 unset($total['compiling']); 209 208 $cacheinfos[] = $total; 210 209 } -
trunk/htdocs/cacher/cacher.tpl.php
r1063 r1064 55 55 $numkeys = explode(',', 'slots,size,avail,hits,updates,skips,ooms,errors,cached,deleted'); 56 56 $l_clear = _('Clear'); 57 $l_disabled = _('Disabled'); 58 $l_disable = _('Disable'); 59 $l_enable = _('Enable'); 60 $l_compiling = _('Compiling'); 61 $l_normal = _('Normal'); 57 62 $l_clear_confirm = _('Sure to clear?'); 58 63 foreach ($cacheinfos as $i => $ci) { … … 92 97 } 93 98 else { 94 if ($ci['type'] == $type_php) { 95 $ci['status'] = $ci['compiling'] ? sprintf(_('Compiling(%s)'), age($ci['compiling'])) : _('Normal'); 99 if ($ci['disabled']) { 100 $ci['status'] = $l_disabled 101 . sprintf("(%s)", age($ci['disabled'])); 102 } 103 else if ($ci['type'] == $type_php) { 104 $ci['status'] = $ci['compiling'] 105 ? $l_compiling . sprintf("(%s)", age($ci['compiling'])) 106 : $l_normal; 96 107 } 97 108 else { … … 100 111 $ci['can_readonly'] = $ci['can_readonly'] ? 'yes' : 'no'; 101 112 } 113 $enabledisable = $ci['disabled'] ? 'enable' : 'disable'; 114 $l_enabledisable = $ci['disabled'] ? $l_enable : $l_disable; 102 115 echo <<<EOS 103 116 <th>{$ci['cache_name']}</th> … … 117 130 /><input type="hidden" name="cacheid" value="{$ci['cacheid']}" 118 131 /><input type="submit" name="clearcache" value="{$l_clear}" class="submit" onclick="return confirm('{$l_clear_confirm}');" 132 /><input type="submit" name="{$enabledisable}" value="{$l_enabledisable}" class="submit" 119 133 /></div 120 134 ></form -
trunk/mod_cacher/xc_cacher.c
r1063 r1064 69 69 70 70 time_t compiling; 71 time_t disabled; 71 72 zend_ulong updates; 72 73 zend_ulong hits; … … 131 132 132 133 typedef enum { XC_TYPE_PHP, XC_TYPE_VAR } xc_entry_type_t; 133 134 /* TODO */135 static inline zend_bool xc_cache_disabled()136 {137 return 0;138 }139 /* }}} */140 134 141 135 /* any function in *_unlocked is only safe be called within locked (single thread access) area */ … … 501 495 { 502 496 TRACE("interval %lu, %lu %lu", (zend_ulong) XG(request_time), (zend_ulong) cache->cached->last_gc_expires, gc_interval); 503 if ( XG(request_time) >= cache->cached->last_gc_expires + (time_t) gc_interval) {497 if (!cache->cached->disabled && XG(request_time) >= cache->cached->last_gc_expires + (time_t) gc_interval) { 504 498 ENTER_LOCK(cache) { 505 499 if (XG(request_time) >= cache->cached->last_gc_expires + (time_t) gc_interval) { … … 563 557 static XC_CACHE_APPLY_FUNC(xc_gc_deletes_one) /* {{{ */ 564 558 { 565 if ( cache->cached->deletes && XG(request_time) - cache->cached->last_gc_deletes > xc_deletes_gc_interval) {559 if (!cache->cached->disabled && cache->cached->deletes && XG(request_time) - cache->cached->last_gc_deletes > xc_deletes_gc_interval) { 566 560 ENTER_LOCK(cache) { 567 561 if (cache->cached->deletes && XG(request_time) - cache->cached->last_gc_deletes > xc_deletes_gc_interval) { … … 614 608 add_assoc_long_ex(return_value, ZEND_STRS("slots"), cache->hentry->size); 615 609 add_assoc_long_ex(return_value, ZEND_STRS("compiling"), cached->compiling); 610 add_assoc_long_ex(return_value, ZEND_STRS("disabled"), cached->disabled); 616 611 add_assoc_long_ex(return_value, ZEND_STRS("updates"), cached->updates); 617 612 add_assoc_long_ex(return_value, ZEND_STRS("misses"), cached->updates); /* deprecated */ … … 2049 2044 xc_sandboxed_compiler_t sandboxed_compiler; 2050 2045 2046 if (cache->cached->disabled) { 2047 return old_compile_file(h, type TSRMLS_CC); 2048 } 2051 2049 /* stale skips precheck */ 2052 if ( XG(request_time) - cache->cached->compiling < 30) {2050 if (cache->cached->disabled || XG(request_time) - cache->cached->compiling < 30) { 2053 2051 cache->cached->skips ++; 2054 2052 return old_compile_file(h, type TSRMLS_CC); … … 2170 2168 || strstr(PG(include_path), "://") != NULL 2171 2169 #endif 2172 || xc_cache_disabled()2173 2170 ) { 2174 2171 TRACE("%s", "cacher not enabled"); … … 2481 2478 static void xc_request_shutdown(TSRMLS_D) /* {{{ */ 2482 2479 { 2483 if (!xc_cache_disabled()) { 2484 xc_entry_unholds(TSRMLS_C); 2485 xc_gc_expires_php(TSRMLS_C); 2486 xc_gc_expires_var(TSRMLS_C); 2487 xc_gc_deletes(TSRMLS_C); 2488 } 2480 xc_entry_unholds(TSRMLS_C); 2481 xc_gc_expires_php(TSRMLS_C); 2482 xc_gc_expires_var(TSRMLS_C); 2483 xc_gc_deletes(TSRMLS_C); 2489 2484 #ifdef ZEND_ENGINE_2 2490 2485 zend_llist_destroy(&XG(gc_op_arrays)); … … 2608 2603 } /* }}} */ 2609 2604 /* {{{ xcache_admin_operate */ 2610 typedef enum { XC_OP_COUNT, XC_OP_INFO, XC_OP_LIST, XC_OP_CLEAR } xcache_op_type;2605 typedef enum { XC_OP_COUNT, XC_OP_INFO, XC_OP_LIST, XC_OP_CLEAR, XC_OP_ENABLE } xcache_op_type; 2611 2606 static void xcache_admin_operate(xcache_op_type optype, INTERNAL_FUNCTION_PARAMETERS) 2612 2607 { … … 2615 2610 xc_cache_t *caches, *cache; 2616 2611 long id = 0; 2612 zend_bool enable = 1; 2617 2613 2618 2614 xcache_admin_auth_check(TSRMLS_C); 2619 2615 2620 if (!xc_initized || xc_cache_disabled()) {2616 if (!xc_initized) { 2621 2617 RETURN_NULL(); 2622 2618 } … … 2628 2624 } 2629 2625 break; 2626 2630 2627 case XC_OP_CLEAR: 2631 2628 id = -1; … … 2634 2631 } 2635 2632 break; 2633 2634 case XC_OP_ENABLE: 2635 id = -1; 2636 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|lb", &type, &id, &enable) == FAILURE) { 2637 return; 2638 } 2639 break; 2640 2636 2641 default: 2637 2642 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &type, &id) == FAILURE) { … … 2699 2704 break; 2700 2705 2706 case XC_OP_ENABLE: 2707 if (!caches || id < -1 || id >= size) { 2708 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cache not exists"); 2709 RETURN_FALSE; 2710 } 2711 2712 if (id == -1) { 2713 for (id = 0; id < size; ++id) { 2714 caches[id].cached->disabled = !enable ? XG(request_time) : 0; 2715 } 2716 } 2717 else { 2718 caches[id].cached->disabled = !enable ? XG(request_time) : 0; 2719 } 2720 2721 break; 2722 2701 2723 default: 2702 2724 assert(0); … … 2732 2754 } 2733 2755 /* }}} */ 2734 2735 #define VAR_DISABLED_WARNING() do { \ 2756 /* {{{ proto array xcache_enable_cache(int type, [ int id = -1, [ bool enable = true ] ]) 2757 Enable or disable cache by id on specified cache type */ 2758 PHP_FUNCTION(xcache_enable_cache) 2759 { 2760 xcache_admin_operate(XC_OP_ENABLE, INTERNAL_FUNCTION_PARAM_PASSTHRU); 2761 } 2762 /* }}} */ 2763 2764 #define VAR_CACHE_NOT_INITIALIZED() do { \ 2736 2765 php_error_docref(NULL TSRMLS_CC, E_WARNING, "XCache var cache was not initialized properly. Check php log for actual reason"); \ 2737 2766 } while (0) … … 2776 2805 zval *name; 2777 2806 2778 if (!xc_var_caches || xc_cache_disabled()) {2779 VAR_ DISABLED_WARNING();2807 if (!xc_var_caches) { 2808 VAR_CACHE_NOT_INITIALIZED(); 2780 2809 RETURN_NULL(); 2781 2810 } … … 2786 2815 xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC); 2787 2816 cache = &xc_var_caches[entry_hash.cacheid]; 2817 2818 if (cache->cached->disabled) { 2819 RETURN_NULL(); 2820 } 2788 2821 2789 2822 ENTER_LOCK(cache) { … … 2810 2843 zval *value; 2811 2844 2812 if (!xc_var_caches || xc_cache_disabled()) {2813 VAR_ DISABLED_WARNING();2845 if (!xc_var_caches) { 2846 VAR_CACHE_NOT_INITIALIZED(); 2814 2847 RETURN_NULL(); 2815 2848 } … … 2832 2865 xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC); 2833 2866 cache = &xc_var_caches[entry_hash.cacheid]; 2867 2868 if (cache->cached->disabled) { 2869 RETURN_NULL(); 2870 } 2834 2871 2835 2872 ENTER_LOCK(cache) { … … 2852 2889 zval *name; 2853 2890 2854 if (!xc_var_caches || xc_cache_disabled()) {2855 VAR_ DISABLED_WARNING();2891 if (!xc_var_caches) { 2892 VAR_CACHE_NOT_INITIALIZED(); 2856 2893 RETURN_FALSE; 2857 2894 } … … 2862 2899 xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC); 2863 2900 cache = &xc_var_caches[entry_hash.cacheid]; 2901 2902 if (cache->cached->disabled) { 2903 RETURN_FALSE; 2904 } 2864 2905 2865 2906 ENTER_LOCK(cache) { … … 2886 2927 zval *name; 2887 2928 2888 if (!xc_var_caches || xc_cache_disabled()) {2889 VAR_ DISABLED_WARNING();2929 if (!xc_var_caches) { 2930 VAR_CACHE_NOT_INITIALIZED(); 2890 2931 RETURN_FALSE; 2891 2932 } … … 2896 2937 xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC); 2897 2938 cache = &xc_var_caches[entry_hash.cacheid]; 2939 2940 if (cache->cached->disabled) { 2941 RETURN_FALSE; 2942 } 2898 2943 2899 2944 ENTER_LOCK(cache) { … … 2916 2961 int i, iend; 2917 2962 2918 if (!xc_var_caches || xc_cache_disabled()) {2919 VAR_ DISABLED_WARNING();2963 if (!xc_var_caches) { 2964 VAR_CACHE_NOT_INITIALIZED(); 2920 2965 RETURN_FALSE; 2921 2966 } … … 2927 2972 for (i = 0, iend = xc_var_hcache.size; i < iend; i ++) { 2928 2973 xc_cache_t *cache = &xc_var_caches[i]; 2974 if (cache->cached->disabled) { 2975 continue; 2976 } 2977 2929 2978 ENTER_LOCK(cache) { 2930 2979 int entryslotid, jend; … … 2952 3001 zval oldzval; 2953 3002 2954 if (!xc_var_caches || xc_cache_disabled()) {2955 VAR_ DISABLED_WARNING();3003 if (!xc_var_caches) { 3004 VAR_CACHE_NOT_INITIALIZED(); 2956 3005 RETURN_NULL(); 2957 3006 } … … 2969 3018 xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC); 2970 3019 cache = &xc_var_caches[entry_hash.cacheid]; 3020 3021 if (cache->cached->disabled) { 3022 RETURN_NULL(); 3023 } 2971 3024 2972 3025 ENTER_LOCK(cache) { … … 3034 3087 PHP_FE(xcache_list, NULL) 3035 3088 PHP_FE(xcache_clear_cache, NULL) 3089 PHP_FE(xcache_enable_cache, NULL) 3036 3090 PHP_FE(xcache_get, NULL) 3037 3091 PHP_FE(xcache_set, NULL) … … 3360 3414 } 3361 3415 /* }}} */ 3416 void xc_cacher_disable() /* {{{ */ 3417 { 3418 time_t now = time(NULL); 3419 size_t i; 3420 3421 if (xc_php_caches) { 3422 for (i = 0; i < xc_php_hcache.size; i ++) { 3423 if (xc_php_caches[i].cached) { 3424 xc_php_caches[i].cached->disabled = now; 3425 } 3426 } 3427 } 3428 3429 if (xc_var_caches) { 3430 for (i = 0; i < xc_var_hcache.size; i ++) { 3431 if (xc_var_caches[i].cached) { 3432 xc_var_caches[i].cached->disabled = now; 3433 } 3434 } 3435 } 3436 } 3437 /* }}} */ -
trunk/mod_cacher/xc_cacher.h
r1044 r1064 7 7 8 8 int xc_cacher_startup_module(); 9 intxc_cacher_disable();9 void xc_cacher_disable(); 10 10 11 11 #endif /* XC_CACHER_H_1CADCD7E46ABC70014D0766CE97B9741 */
Note: See TracChangeset
for help on using the changeset viewer.

