Changeset 1146
- Timestamp:
- 2012-08-23T10:27:54+02:00 (9 months ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
ChangeLog (modified) (2 diffs)
-
NEWS (modified) (1 diff)
-
htdocs/cacher/edit.php (modified) (1 diff)
-
htdocs/cacher/edit.tpl.php (modified) (1 diff)
-
htdocs/cacher/index.php (modified) (1 diff)
-
htdocs/cacher/sub/entrylist.tpl.php (modified) (3 diffs)
-
mod_cacher/xc_cacher.c (modified) (29 diffs)
-
xcache_globals.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r1140 r1146 4 4 * chg: proto array xcache_clear_cache(int type, [ int id = -1 ]). -1 means all cache splits 5 5 * new: proto array xcache_enable_cache(int type, [ int id = -1, [ bool enable = true ] ]) 6 * new: proto array xcache_admin_namespace() 7 * new: proto array xcache_set_namespace(string namespace) 6 8 7 9 Ini Settings Changes … … 18 20 * closes #174: updates api to support "clear all cache" 19 21 * closes #198: support for caching protocol url 22 * closes #287: namespace support 20 23 * fixes #39: ini_set never work for xcache.coverager setting. use API instead 21 24 * code refactor -
trunk/NEWS
r1139 r1146 6 6 * uses extension= to load XCache. loading via zend_extension= is unsupported 7 7 * updates XCache admin page 8 * namespace support 8 9 * professional helpers 9 10 * adds an diagnosis module to give advise @ htdocs -
trunk/htdocs/cacher/edit.php
r1144 r1146 7 7 } 8 8 9 $name = $_GET['name'];10 9 // trigger auth 11 10 $vcnt = xcache_count(XC_TYPE_VAR); 11 xcache_admin_namespace(); 12 13 $name = $_GET['name']; 14 if (!empty($config['enable_eval'])) { 15 eval('$name = ' . $name . ';'); 16 } 12 17 13 18 if ($_SERVER['REQUEST_METHOD'] == 'POST') { -
trunk/htdocs/cacher/edit.tpl.php
r1086 r1146 1 1 <?php include "../common/header.tpl.php"; ?> 2 2 <?php 3 $h_name = htmlspecialchars( $name);3 $h_name = htmlspecialchars(var_export($name, true)); 4 4 $h_value = htmlspecialchars($value); 5 5 ?> -
trunk/htdocs/cacher/index.php
r1145 r1146 258 258 259 259 xcache_count(XC_TYPE_PHP); // trigger auth 260 xcache_admin_namespace(); 260 261 261 262 $doTypes = array( -
trunk/htdocs/cacher/sub/entrylist.tpl.php
r1143 r1146 61 61 62 62 TR; 63 $name = htmlspecialchars($entry['name']);64 63 $hits = number_format($entry['hits']); 65 64 $size = size($entry['size']); … … 81 80 82 81 if ($isphp) { 83 $namelink = $name; 82 $hname = htmlspecialchars($entry['name']); 83 $namelink = $hname; 84 84 echo <<<ENTRY 85 85 <td>{$entry['cache_name']} {$i}</td> … … 88 88 } 89 89 else { 90 $name = $entry['name']; 91 if (!empty($config['enable_eval'])) { 92 $name = var_export($name, true); 93 } 94 $uname = urlencode($name); 95 $hname = htmlspecialchars(str_replace("\0", "\\0", $entry['name'])); 90 96 echo <<<ENTRY 91 <td><label><input type="checkbox" name="remove[]" value="{$ name}"/>{$entry['cache_name']} {$i}</label></td>97 <td><label><input type="checkbox" name="remove[]" value="{$hname}"/>{$entry['cache_name']} {$i}</label></td> 92 98 93 99 ENTRY; 94 $uname = urlencode($entry['name']); 95 $namelink = "<a href=\"edit.php?name=$uname\">$name</a>"; 100 $namelink = "<a href=\"edit.php?name=$uname\">$hname</a>"; 96 101 } 97 102 -
trunk/mod_cacher/xc_cacher.c
r1140 r1146 144 144 145 145 static zend_bool xc_readonly_protection = 0; 146 147 static zend_ulong xc_var_namespace_mode = 0; 148 static char *xc_var_namespace = NULL; 149 146 150 147 151 zend_bool xc_have_op_array_ctor = 0; … … 257 261 if (entry1->name_type == IS_UNICODE) { 258 262 return entry1->name.ustr.len == entry2->name.ustr.len 259 && memcmp(entry1->name.ustr.val, entry2->name.ustr.val, (entry1->name.ustr.len + 1) * sizeof( UChar)) == 0;263 && memcmp(entry1->name.ustr.val, entry2->name.ustr.val, (entry1->name.ustr.len + 1) * sizeof(entry1->name.ustr.val[0])) == 0; 260 264 } 261 265 #endif … … 268 272 } 269 273 return 0; 270 }271 /* }}} */272 static inline int xc_entry_has_prefix_unlocked(xc_entry_type_t type, xc_entry_t *entry, zval *prefix) /* {{{ */273 {274 /* this function isn't required but can be in unlocked */275 276 #ifdef IS_UNICODE277 if (entry->name_type != prefix->type) {278 return 0;279 }280 281 if (entry->name_type == IS_UNICODE) {282 if (entry->name.ustr.len < Z_USTRLEN_P(prefix)) {283 return 0;284 }285 return memcmp(entry->name.ustr.val, Z_USTRVAL_P(prefix), Z_USTRLEN_P(prefix) * sizeof(UChar)) == 0;286 }287 #endif288 if (prefix->type != IS_STRING) {289 return 0;290 }291 292 if (entry->name.str.len < Z_STRLEN_P(prefix)) {293 return 0;294 }295 296 return memcmp(entry->name.str.val, Z_STRVAL_P(prefix), Z_STRLEN_P(prefix)) == 0;297 274 } 298 275 /* }}} */ … … 2307 2284 /* }}} */ 2308 2285 2286 /* variable namespace */ 2287 #ifdef IS_UNICODE 2288 void xc_var_namespace_init_from_unicodel(const UChar *string, int len TSRMLS_DC) /* {{{ */ 2289 { 2290 if (!len) { 2291 #ifdef IS_UNICODE 2292 ZVAL_EMPTY_UNICODE(&XG(uvar_namespace_hard)); 2293 #endif 2294 ZVAL_EMPTY_STRING(&XG(var_namespace_hard)); 2295 } 2296 else { 2297 ZVAL_UNICODE_L(&XG(uvar_namespace_hard), string, len, 1); 2298 /* TODO: copy to var */ 2299 } 2300 } 2301 /* }}} */ 2302 #endif 2303 void xc_var_namespace_init_from_stringl(const char *string, int len TSRMLS_DC) /* {{{ */ 2304 { 2305 if (!len) { 2306 #ifdef IS_UNICODE 2307 ZVAL_EMPTY_UNICODE(&XG(uvar_namespace_hard)); 2308 #endif 2309 ZVAL_EMPTY_STRING(&XG(var_namespace_hard)); 2310 } 2311 else { 2312 ZVAL_STRINGL(&XG(var_namespace_hard), string, len, 1); 2313 #ifdef IS_UNICODE 2314 /* TODO: copy to uvar */ 2315 #endif 2316 } 2317 } 2318 /* }}} */ 2319 void xc_var_namespace_init_from_long(long value TSRMLS_DC) /* {{{ */ 2320 { 2321 ZVAL_LONG(&XG(var_namespace_hard), value); 2322 #ifdef IS_UNICODE 2323 /* TODO: copy to uvar_namespace */ 2324 #endif 2325 } 2326 /* }}} */ 2327 #ifdef IS_UNICODE 2328 void xc_var_namespace_set_unicodel(const UChar *unicode, int len TSRMLS_DC) /* {{{ */ 2329 { 2330 zval_dtor(&XG(uvar_namespace_soft)); 2331 zval_dtor(&XG(var_namespace_soft)); 2332 if (len) { 2333 if (!Z_USTRLEN_P(&XG(uvar_namespace_soft))) { 2334 ZVAL_UNICODEL(&XG(uvar_namespace_soft), unicode, len, 1); 2335 } 2336 else { 2337 int buffer_len = Z_USTRLEN_P(&XG(var_namespace_hard)) + 1 + len; 2338 char *buffer = emalloc((buffer_len + 1) * sizeof(unicode[0])); 2339 char *p = buffer; 2340 memcpy(p, Z_USTRVAL_P(&XG(var_namespace_hard)), (Z_USTRLEN_P(&XG(var_namespace_hard)) + 1)); 2341 p += (Z_USTRLEN_P(&XG(var_namespace_hard)) + 1) * sizeof(unicode[0]); 2342 memcpy(p, unicode, (len + 1) * sizeof(unicode[0])); 2343 ZVAL_UNICODEL(&XG(uvar_namespace_soft), buffer, buffer_len, 0); 2344 } 2345 /* TODO: copy to var */ 2346 } 2347 else { 2348 #ifdef IS_UNICODE 2349 XG(uvar_namespace_soft) = XG(uvar_namespace_hard); 2350 zval_copy_ctor(&XG(uvar_namespace_soft)); 2351 #endif 2352 XG(var_namespace_soft) = XG(var_namespace_hard); 2353 zval_copy_ctor(&XG(var_namespace_soft)); 2354 } 2355 } 2356 /* }}} */ 2357 #endif 2358 void xc_var_namespace_set_stringl(const char *string, int len TSRMLS_DC) /* {{{ */ 2359 { 2360 #ifdef IS_UNICODE 2361 zval_dtor(&XG(uvar_namespace_soft)); 2362 #endif 2363 zval_dtor(&XG(var_namespace_soft)); 2364 if (len) { 2365 if (!Z_STRLEN_P(&XG(var_namespace_soft))) { 2366 ZVAL_STRINGL(&XG(var_namespace_soft), string, len, 1); 2367 } 2368 else { 2369 int buffer_len = Z_STRLEN_P(&XG(var_namespace_hard)) + 1 + len; 2370 char *buffer = emalloc(buffer_len + 1); 2371 char *p = buffer; 2372 memcpy(p, Z_STRVAL_P(&XG(var_namespace_hard)), Z_STRLEN_P(&XG(var_namespace_hard)) + 1); 2373 p += Z_STRLEN_P(&XG(var_namespace_hard)) + 1; 2374 memcpy(p, string, len + 1); 2375 ZVAL_STRINGL(&XG(var_namespace_soft), buffer, buffer_len, 0); 2376 } 2377 #ifdef IS_UNICODE 2378 /* TODO: copy to uvar */ 2379 #endif 2380 } 2381 else { 2382 #ifdef IS_UNICODE 2383 XG(uvar_namespace_soft) = XG(uvar_namespace_hard); 2384 zval_copy_ctor(&XG(uvar_namespace_soft)); 2385 #endif 2386 XG(var_namespace_soft) = XG(var_namespace_hard); 2387 zval_copy_ctor(&XG(var_namespace_soft)); 2388 } 2389 } 2390 /* }}} */ 2391 static void xc_var_namespace_break(TSRMLS_D) /* {{{ */ 2392 { 2393 #ifdef IS_UNICODE 2394 zval_dtor(&XG(uvar_namespace_soft)); 2395 #endif 2396 zval_dtor(&XG(var_namespace_soft)); 2397 #ifdef IS_UNICODE 2398 ZVAL_EMPTY_UNICODE(&XG(uvar_namespace_soft)); 2399 #endif 2400 ZVAL_EMPTY_STRING(&XG(var_namespace_soft)); 2401 } 2402 /* }}} */ 2403 static void xc_var_namespace_init(TSRMLS_D) /* {{{ */ 2404 { 2405 uid_t id = (uid_t) -1; 2406 2407 switch (xc_var_namespace_mode) { 2408 case 1: 2409 { 2410 zval **server; 2411 HashTable *ht; 2412 zval **val; 2413 2414 #ifdef ZEND_ENGINE_2_1 2415 zend_is_auto_global("_SERVER", sizeof("_SERVER") - 1 TSRMLS_CC); 2416 #endif 2417 2418 if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void**)&server) == FAILURE 2419 || Z_TYPE_PP(server) != IS_ARRAY 2420 || !(ht = Z_ARRVAL_P(*server)) 2421 || zend_hash_find(ht, xc_var_namespace, strlen(xc_var_namespace) + 1, (void**)&val) == FAILURE) { 2422 xc_var_namespace_init_from_stringl(NULL, 0 TSRMLS_CC); 2423 } 2424 else { 2425 #ifdef IS_UNICODE 2426 if (Z_TYPE_PP(val) == IS_UNICODE) { 2427 xc_var_namespace_init_from_unicodel(Z_USTRVAL_PP(val), Z_USTRLEN_PP(val) TSRMLS_CC); 2428 } 2429 else 2430 #endif 2431 { 2432 xc_var_namespace_init_from_stringl(Z_STRVAL_PP(val), Z_STRLEN_PP(val) TSRMLS_CC); 2433 } 2434 } 2435 } 2436 break; 2437 2438 case 2: 2439 if (strncmp(xc_var_namespace, "uid", 3) == 0) { 2440 id = getuid(); 2441 } 2442 else if (strncmp(xc_var_namespace, "gid", 3) == 0) { 2443 id = getgid(); 2444 } 2445 2446 if (id == (uid_t) -1){ 2447 xc_var_namespace_init_from_stringl(NULL, 0 TSRMLS_CC); 2448 } 2449 else { 2450 xc_var_namespace_init_from_long((long) id TSRMLS_CC); 2451 } 2452 break; 2453 2454 case 0: 2455 default: 2456 xc_var_namespace_init_from_stringl(xc_var_namespace, strlen(xc_var_namespace) TSRMLS_CC); 2457 break; 2458 } 2459 2460 #ifdef IS_UNICODE 2461 INIT_ZVAL(XG(uvar_namespace_soft)); 2462 #endif 2463 INIT_ZVAL(XG(var_namespace_soft)); 2464 xc_var_namespace_set_stringl("", 0 TSRMLS_CC); 2465 } 2466 /* }}} */ 2467 static void xc_var_namespace_destroy(TSRMLS_D) /* {{{ */ 2468 { 2469 #ifdef IS_UNICODE 2470 zval_dtor(&XG(uvar_namespace_hard)); 2471 zval_dtor(&XG(uvar_namespace_soft)); 2472 #endif 2473 zval_dtor(&XG(var_namespace_hard)); 2474 zval_dtor(&XG(var_namespace_soft)); 2475 } 2476 /* }}} */ 2477 static int xc_var_buffer_prepare(zval *name TSRMLS_DC) /* {{{ prepare name, calculate buffer size */ 2478 { 2479 int namespace_len; 2480 switch (name->type) { 2481 #ifdef IS_UNICODE 2482 case IS_UNICODE: 2483 do_unicode: 2484 namespace_len = Z_USTRLEN_P(&XG(uvar_namespace_soft)); 2485 return (namespace_len ? namespace_len + 1 : 0) + Z_USTRLEN_P(name); 2486 #endif 2487 2488 case IS_STRING: 2489 do_string: 2490 namespace_len = Z_STRLEN_P(&XG(var_namespace_soft)); 2491 return (namespace_len ? namespace_len + 1 : 0) + Z_STRLEN_P(name); 2492 2493 default: 2494 #ifdef IS_UNICODE 2495 convert_to_unicode(name); 2496 goto do_unicode; 2497 #else 2498 convert_to_string(name); 2499 goto do_string; 2500 #endif 2501 } 2502 } 2503 /* }}} */ 2504 static int xc_var_buffer_alloca_size(zval *name TSRMLS_DC) /* {{{ prepare name, calculate buffer size */ 2505 { 2506 int namespace_len; 2507 switch (name->type) { 2508 #ifdef IS_UNICODE 2509 case IS_UNICODE: 2510 namespace_len = Z_USTRLEN_P(&XG(uvar_namespace_soft)); 2511 return !namespace_len ? 0 : (namespace_len + 1 + Z_USTRLEN_P(name) + 1) * sizeof(Z_USTRVAL_P(&XG(uvar_namespace_soft))[0]); 2512 #endif 2513 2514 case IS_STRING: 2515 namespace_len = Z_STRLEN_P(&XG(var_namespace_soft)); 2516 return !namespace_len ? 0 : (namespace_len + 1 + Z_STRLEN_P(name) + 1); 2517 } 2518 assert(0); 2519 return 0; 2520 } 2521 /* }}} */ 2522 static void xc_var_buffer_init(char *buffer, zval *name TSRMLS_DC) /* {{{ prepare name, calculate buffer size */ 2523 { 2524 #ifdef IS_UNICODE 2525 if (Z_TYPE(name) == IS_UNICODE) { 2526 memcpy(buffer, Z_USTRVAL_P(&XG(uvar_namespace_soft)), (Z_USTRLEN_P(&XG(uvar_namespace_soft)) + 1) * sizeof(Z_USTRVAL_P(name)[0])); 2527 buffer += (Z_USTRLEN_P(&XG(uvar_namespace_soft)) + 1) * sizeof(Z_USTRVAL_P(name)[0]); 2528 memcpy(buffer, Z_USTRVAL_P(name), (Z_USTRLEN_P(name) + 1) * sizeof(Z_USTRVAL_P(name)[0])); 2529 } 2530 #endif 2531 memcpy(buffer, Z_STRVAL_P(&XG(var_namespace_soft)), (Z_STRLEN_P(&XG(var_namespace_soft)) + 1)); 2532 buffer += (Z_STRLEN_P(&XG(var_namespace_soft)) + 1); 2533 memcpy(buffer, Z_STRVAL_P(name), (Z_STRLEN_P(name) + 1)); 2534 } 2535 /* }}} */ 2536 typedef struct xc_namebuffer_t_ { /* {{{ */ 2537 ALLOCA_FLAG(useheap); 2538 void *buffer; 2539 int alloca_size; 2540 int len; 2541 } xc_namebuffer_t; 2542 /* }}} */ 2543 2544 #define VAR_BUFFER_FLAGS(name) \ 2545 xc_namebuffer_t name##_buffer; 2546 2547 #define VAR_BUFFER_INIT(name) \ 2548 name##_buffer.len = xc_var_buffer_prepare(name TSRMLS_CC); \ 2549 name##_buffer.alloca_size = xc_var_buffer_alloca_size(name TSRMLS_CC); \ 2550 name##_buffer.buffer = name##_buffer.alloca_size \ 2551 ? do_alloca(name##_buffer.alloca_size, name##_buffer.useheap) \ 2552 : UNISW(Z_STRVAL_P(name), Z_TYPE(name) == IS_UNICODE ? Z_USTRVAL_P(name) : Z_STRVAL_P(name)); \ 2553 if (name##_buffer.alloca_size) xc_var_buffer_init(name##_buffer.buffer, name TSRMLS_CC); 2554 2555 #define VAR_BUFFER_FREE(name) \ 2556 if (name##_buffer.alloca_size) { \ 2557 free_alloca(name##_buffer.buffer, name##_buffer.useheap); \ 2558 } 2559 2560 static inline int xc_var_has_prefix(xc_entry_t *entry, zval *prefix TSRMLS_DC) /* {{{ */ 2561 { 2562 zend_bool result = 0; 2563 VAR_BUFFER_FLAGS(prefix); 2564 2565 if (UNISW(IS_STRING, entry->name_type) != prefix->type) { 2566 return 0; 2567 } 2568 VAR_BUFFER_INIT(prefix); 2569 2570 #ifdef IS_UNICODE 2571 if (Z_TYPE(prefix) == IS_UNICODE) { 2572 result = entry->name.ustr.len >= prefix_buffer.len 2573 && memcmp(entry->name.ustr.val, prefix_buffer.buffer, prefix_buffer.len * sizeof(Z_USTRVAL_P(prefix)[0])) == 0; 2574 goto finish; 2575 } 2576 #endif 2577 2578 result = entry->name.str.len >= prefix_buffer.len 2579 && memcmp(entry->name.str.val, prefix_buffer.buffer, prefix_buffer.len) == 0; 2580 goto finish; 2581 2582 finish: 2583 VAR_BUFFER_FREE(prefix); 2584 return result; 2585 } 2586 /* }}} */ 2587 2309 2588 /* module helper function */ 2310 2589 static int xc_init_constant(int module_number TSRMLS_DC) /* {{{ */ … … 2502 2781 } 2503 2782 } 2504 2783 xc_var_namespace_init(TSRMLS_C); 2505 2784 #ifdef ZEND_ENGINE_2 2506 2785 zend_llist_init(&XG(gc_op_arrays), sizeof(xc_gc_op_array_t), xc_gc_op_array, 0); … … 2520 2799 xc_gc_expires_var(TSRMLS_C); 2521 2800 xc_gc_deletes(TSRMLS_C); 2801 xc_var_namespace_destroy(TSRMLS_C); 2522 2802 #ifdef ZEND_ENGINE_2 2523 2803 zend_llist_destroy(&XG(gc_op_arrays)); … … 2566 2846 zend_bailout(); 2567 2847 } 2568 ht = HASH_OF((*server));2848 ht = Z_ARRVAL_P((*server)); 2569 2849 2570 2850 if (zend_hash_find(ht, "PHP_AUTH_USER", sizeof("PHP_AUTH_USER"), (void **) &user) == FAILURE) { … … 2799 3079 } 2800 3080 /* }}} */ 3081 /* {{{ proto mixed xcache_admin_namespace() 3082 Break out of namespace limitation */ 3083 PHP_FUNCTION(xcache_admin_namespace) 3084 { 3085 xcache_admin_auth_check(TSRMLS_C); 3086 xc_var_namespace_break(TSRMLS_C); 3087 } 3088 /* }}} */ 2801 3089 2802 3090 #define VAR_CACHE_NOT_INITIALIZED() do { \ … … 2804 3092 } while (0) 2805 3093 2806 static int xc_entry_var_init_key(xc_entry_var_t *entry_var, xc_entry_hash_t *entry_hash, zval *nameTSRMLS_DC) /* {{{ */3094 static int xc_entry_var_init_key(xc_entry_var_t *entry_var, xc_entry_hash_t *entry_hash, xc_namebuffer_t *name_buffer TSRMLS_DC) /* {{{ */ 2807 3095 { 2808 3096 xc_hash_value_t hv; 2809 2810 switch (name->type) {2811 #ifdef IS_UNICODE2812 case IS_UNICODE:2813 case IS_STRING:2814 #endif2815 default:2816 #ifdef IS_UNICODE2817 convert_to_unicode(name);2818 #else2819 convert_to_string(name);2820 #endif2821 }2822 3097 2823 3098 #ifdef IS_UNICODE 2824 3099 entry_var->name_type = name->type; 2825 3100 #endif 2826 entry_var->entry.name = name->value; 3101 entry_var->entry.name.str.val = name_buffer->buffer; 3102 entry_var->entry.name.str.len = name_buffer->len; 2827 3103 2828 3104 hv = xc_entry_hash_var((xc_entry_t *) entry_var TSRMLS_CC); … … 2834 3110 } 2835 3111 /* }}} */ 3112 /* {{{ proto mixed xcache_set_namespace(string namespace) 3113 Switch to user defined namespace */ 3114 PHP_FUNCTION(xcache_set_namespace) 3115 { 3116 zval *namespace; 3117 3118 if (!xc_var_caches) { 3119 VAR_CACHE_NOT_INITIALIZED(); 3120 RETURN_NULL(); 3121 } 3122 3123 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &namespace) == FAILURE) { 3124 return; 3125 } 3126 3127 if (Z_TYPE_P(namespace) == IS_STRING) { 3128 xc_var_namespace_set_stringl(Z_STRVAL_P(namespace), Z_STRLEN_P(namespace) TSRMLS_CC); 3129 } 3130 #ifdef IS_UNICODE 3131 else if (Z_TYPE_P(namespace) == IS_UNICODE) { 3132 xc_var_namespace_set_unicodel(Z_USTRVAL_P(namespace), Z_USTRLEN_P(namespace) TSRMLS_CC); 3133 } 3134 #endif 3135 } 3136 /* }}} */ 2836 3137 /* {{{ proto mixed xcache_get(string name) 2837 3138 Get cached data by specified name */ … … 2842 3143 xc_entry_var_t entry_var, *stored_entry_var; 2843 3144 zval *name; 3145 VAR_BUFFER_FLAGS(name); 2844 3146 2845 3147 if (!xc_var_caches) { … … 2851 3153 return; 2852 3154 } 2853 xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC); 3155 VAR_BUFFER_INIT(name); 3156 xc_entry_var_init_key(&entry_var, &entry_hash, &name_buffer TSRMLS_CC); 2854 3157 cache = &xc_var_caches[entry_hash.cacheid]; 2855 3158 2856 3159 if (cache->cached->disabled) { 3160 VAR_BUFFER_FREE(name); 2857 3161 RETURN_NULL(); 2858 3162 } … … 2869 3173 } 2870 3174 } LEAVE_LOCK(cache); 3175 VAR_BUFFER_FREE(name); 2871 3176 } 2872 3177 /* }}} */ … … 2880 3185 zval *name; 2881 3186 zval *value; 3187 VAR_BUFFER_FLAGS(name); 2882 3188 2883 3189 if (!xc_var_caches) { … … 2901 3207 } 2902 3208 2903 xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC); 3209 VAR_BUFFER_INIT(name); 3210 xc_entry_var_init_key(&entry_var, &entry_hash, &name_buffer TSRMLS_CC); 2904 3211 cache = &xc_var_caches[entry_hash.cacheid]; 2905 3212 2906 3213 if (cache->cached->disabled) { 3214 VAR_BUFFER_FREE(name); 2907 3215 RETURN_NULL(); 2908 3216 } … … 2916 3224 RETVAL_BOOL(xc_entry_var_store_unlocked(cache, entry_hash.entryslotid, &entry_var TSRMLS_CC) != NULL ? 1 : 0); 2917 3225 } LEAVE_LOCK(cache); 3226 VAR_BUFFER_FREE(name); 2918 3227 } 2919 3228 /* }}} */ … … 2926 3235 xc_entry_var_t entry_var, *stored_entry_var; 2927 3236 zval *name; 3237 VAR_BUFFER_FLAGS(name); 2928 3238 2929 3239 if (!xc_var_caches) { … … 2935 3245 return; 2936 3246 } 2937 xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC); 3247 VAR_BUFFER_INIT(name); 3248 xc_entry_var_init_key(&entry_var, &entry_hash, &name_buffer TSRMLS_CC); 2938 3249 cache = &xc_var_caches[entry_hash.cacheid]; 2939 3250 2940 3251 if (cache->cached->disabled) { 3252 VAR_BUFFER_FREE(name); 2941 3253 RETURN_FALSE; 2942 3254 } … … 2954 3266 2955 3267 } LEAVE_LOCK(cache); 3268 VAR_BUFFER_FREE(name); 2956 3269 } 2957 3270 /* }}} */ … … 2964 3277 xc_entry_var_t entry_var, *stored_entry_var; 2965 3278 zval *name; 3279 VAR_BUFFER_FLAGS(name); 2966 3280 2967 3281 if (!xc_var_caches) { … … 2973 3287 return; 2974 3288 } 2975 xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC); 3289 VAR_BUFFER_INIT(name); 3290 xc_entry_var_init_key(&entry_var, &entry_hash, &name_buffer TSRMLS_CC); 2976 3291 cache = &xc_var_caches[entry_hash.cacheid]; 2977 3292 2978 3293 if (cache->cached->disabled) { 3294 VAR_BUFFER_FREE(name); 2979 3295 RETURN_FALSE; 2980 3296 } … … 2990 3306 } 2991 3307 } LEAVE_LOCK(cache); 3308 VAR_BUFFER_FREE(name); 2992 3309 } 2993 3310 /* }}} */ … … 3020 3337 for (entry = cache->cached->entries[entryslotid]; entry; entry = next) { 3021 3338 next = entry->next; 3022 if (xc_ entry_has_prefix_unlocked(XC_TYPE_VAR, entry, prefix)) {3339 if (xc_var_has_prefix(entry, prefix TSRMLS_CC)) { 3023 3340 xc_entry_remove_unlocked(XC_TYPE_VAR, cache, entryslotid, entry TSRMLS_CC); 3024 3341 } … … 3038 3355 long value = 0; 3039 3356 zval oldzval; 3357 VAR_BUFFER_FLAGS(name); 3040 3358 3041 3359 if (!xc_var_caches) { … … 3054 3372 } 3055 3373 3056 xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC); 3374 VAR_BUFFER_INIT(name); 3375 xc_entry_var_init_key(&entry_var, &entry_hash, &name_buffer TSRMLS_CC); 3057 3376 cache = &xc_var_caches[entry_hash.cacheid]; 3058 3377 3059 3378 if (cache->cached->disabled) { 3379 VAR_BUFFER_FREE(name); 3060 3380 RETURN_NULL(); 3061 3381 } … … 3103 3423 xc_entry_var_store_unlocked(cache, entry_hash.entryslotid, &entry_var TSRMLS_CC); 3104 3424 } LEAVE_LOCK(cache); 3425 VAR_BUFFER_FREE(name); 3105 3426 } 3106 3427 /* }}} */ … … 3126 3447 PHP_FE(xcache_clear_cache, NULL) 3127 3448 PHP_FE(xcache_enable_cache, NULL) 3449 PHP_FE(xcache_admin_namespace, NULL) 3450 PHP_FE(xcache_set_namespace, NULL) 3128 3451 PHP_FE(xcache_get, NULL) 3129 3452 PHP_FE(xcache_set, NULL) … … 3221 3544 PHP_INI_ENTRY1 ("xcache.var_allocator", "bestfit", PHP_INI_SYSTEM, xcache_OnUpdateString, &xc_var_allocator) 3222 3545 STD_PHP_INI_ENTRY ("xcache.var_ttl", "0", PHP_INI_ALL, OnUpdateLong, var_ttl, zend_xcache_globals, xcache_globals) 3546 PHP_INI_ENTRY1 ("xcache.var_namespace_mode", "0", PHP_INI_SYSTEM, xcache_OnUpdateULong, &xc_var_namespace_mode) 3547 PHP_INI_ENTRY1 ("xcache.var_namespace", "", PHP_INI_SYSTEM, xcache_OnUpdateString, &xc_var_namespace) 3223 3548 PHP_INI_END() 3224 3549 /* }}} */ … … 3394 3719 pefree(xc_var_allocator, 1); 3395 3720 xc_var_allocator = NULL; 3721 } 3722 if (xc_var_namespace) { 3723 pefree(xc_var_namespace, 1); 3724 xc_var_namespace = NULL; 3396 3725 } 3397 3726 -
trunk/xcache_globals.h
r1118 r1146 21 21 time_t request_time; 22 22 long var_ttl; 23 #ifdef IS_UNCODE 24 zval uvar_namespace_hard; 25 zval uvar_namespace_soft; 26 #endif 27 zval var_namespace_hard; 28 zval var_namespace_soft; 23 29 24 30 zend_llist gc_op_arrays;
Note: See TracChangeset
for help on using the changeset viewer.

