Changeset 1062 for trunk/mod_cacher/xc_cacher.c
- Timestamp:
- 2012-07-27T17:10:17+02:00 (10 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
mod_cacher/xc_cacher.c (modified) (58 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 18 18 devel.ini 19 19 devel.php 20 devel.fpm 20 21 .gdb_history 21 22 include
-
- Property svn:ignore
-
trunk/mod_cacher/xc_cacher.c
r1057 r1062 59 59 /* }}} */ 60 60 61 /* {{{ types */ 62 struct _xc_hash_t { 61 struct _xc_hash_t { /* {{{ */ 63 62 size_t bits; 64 63 size_t size; 65 64 xc_hash_value_t mask; 65 }; 66 /* }}} */ 67 struct _xc_cached_t { /* {{{ stored in shm */ 68 int cacheid; 69 70 time_t compiling; 71 zend_ulong updates; 72 zend_ulong hits; 73 zend_ulong clogs; 74 zend_ulong ooms; 75 zend_ulong errors; 76 77 xc_entry_t **entries; 78 int entries_count; 79 xc_entry_data_php_t **phps; 80 int phps_count; 81 xc_entry_t *deletes; 82 int deletes_count; 83 84 time_t last_gc_deletes; 85 time_t last_gc_expires; 86 87 time_t hits_by_hour_cur_time; 88 zend_uint hits_by_hour_cur_slot; 89 zend_ulong hits_by_hour[24]; 90 time_t hits_by_second_cur_time; 91 zend_uint hits_by_second_cur_slot; 92 zend_ulong hits_by_second[5]; 66 93 }; 67 94 /* }}} */ … … 88 115 static zend_ulong xc_var_size = 0; 89 116 90 static xc_cache_t * *xc_php_caches = NULL;91 static xc_cache_t * *xc_var_caches = NULL;117 static xc_cache_t *xc_php_caches = NULL; 118 static xc_cache_t *xc_var_caches = NULL; 92 119 93 120 static zend_bool xc_initized = 0; … … 114 141 /* any function in *_unlocked is only safe be called within locked (single thread access) area */ 115 142 116 static void xc_php_add_unlocked(xc_cache _t *cache, xc_entry_data_php_t *php) /* {{{ */117 { 118 xc_entry_data_php_t **head = &(cache ->phps[php->hvalue]);143 static void xc_php_add_unlocked(xc_cached_t *cached, xc_entry_data_php_t *php) /* {{{ */ 144 { 145 xc_entry_data_php_t **head = &(cached->phps[php->hvalue]); 119 146 php->next = *head; 120 147 *head = php; 121 cache ->phps_count ++;148 cached->phps_count ++; 122 149 } 123 150 /* }}} */ … … 130 157 stored_php = xc_processor_store_xc_entry_data_php_t(cache, php TSRMLS_CC); 131 158 if (stored_php) { 132 xc_php_add_unlocked(cache , stored_php);159 xc_php_add_unlocked(cache->cached, stored_php); 133 160 return stored_php; 134 161 } 135 162 else { 136 cache-> ooms ++;163 cache->cached->ooms ++; 137 164 return NULL; 138 165 } 139 166 } 140 167 /* }}} */ 141 static xc_entry_data_php_t *xc_php_find_unlocked(xc_cache _t *cache, xc_entry_data_php_t *php TSRMLS_DC) /* {{{ */168 static xc_entry_data_php_t *xc_php_find_unlocked(xc_cached_t *cached, xc_entry_data_php_t *php TSRMLS_DC) /* {{{ */ 142 169 { 143 170 xc_entry_data_php_t *p; 144 for (p = cache ->phps[php->hvalue]; p; p = (xc_entry_data_php_t *) p->next) {171 for (p = cached->phps[php->hvalue]; p; p = (xc_entry_data_php_t *) p->next) { 145 172 if (memcmp(&php->md5.digest, &p->md5.digest, sizeof(php->md5.digest)) == 0) { 146 173 p->hits ++; … … 164 191 { 165 192 if (-- php->refcount == 0) { 166 xc_entry_data_php_t **pp = &(cache-> phps[php->hvalue]);193 xc_entry_data_php_t **pp = &(cache->cached->phps[php->hvalue]); 167 194 xc_entry_data_php_t *p; 168 195 for (p = *pp; p; pp = &(p->next), p = p->next) { … … 259 286 } 260 287 /* }}} */ 261 static void xc_entry_add_unlocked(xc_cache _t *cache, xc_hash_value_t entryslotid, xc_entry_t *entry) /* {{{ */262 { 263 xc_entry_t **head = &(cache ->entries[entryslotid]);288 static void xc_entry_add_unlocked(xc_cached_t *cached, xc_hash_value_t entryslotid, xc_entry_t *entry) /* {{{ */ 289 { 290 xc_entry_t **head = &(cached->entries[entryslotid]); 264 291 entry->next = *head; 265 292 *head = entry; 266 cache ->entries_count ++;293 cached->entries_count ++; 267 294 } 268 295 /* }}} */ … … 278 305 : (xc_entry_t *) xc_processor_store_xc_entry_var_t(cache, (xc_entry_var_t *) entry TSRMLS_CC); 279 306 if (stored_entry) { 280 xc_entry_add_unlocked(cache , entryslotid, stored_entry);281 ++cache-> updates;307 xc_entry_add_unlocked(cache->cached, entryslotid, stored_entry); 308 ++cache->cached->updates; 282 309 return stored_entry; 283 310 } 284 311 else { 285 cache-> ooms ++;312 cache->cached->ooms ++; 286 313 return NULL; 287 314 } … … 308 335 static void xc_entry_free_unlocked(xc_entry_type_t type, xc_cache_t *cache, xc_entry_t *entry TSRMLS_DC) /* {{{ */ 309 336 { 310 cache-> entries_count --;337 cache->cached->entries_count --; 311 338 if ((type == XC_TYPE_PHP ? ((xc_entry_php_t *) entry)->refcount : 0) == 0) { 312 339 xc_entry_free_real_unlocked(type, cache, entry); 313 340 } 314 341 else { 315 entry->next = cache-> deletes;316 cache-> deletes = entry;342 entry->next = cache->cached->deletes; 343 cache->cached->deletes = entry; 317 344 entry->dtime = XG(request_time); 318 cache-> deletes_count ++;345 cache->cached->deletes_count ++; 319 346 } 320 347 return; … … 323 350 static void xc_entry_remove_unlocked(xc_entry_type_t type, xc_cache_t *cache, xc_hash_value_t entryslotid, xc_entry_t *entry TSRMLS_DC) /* {{{ */ 324 351 { 325 xc_entry_t **pp = &(cache-> entries[entryslotid]);352 xc_entry_t **pp = &(cache->cached->entries[entryslotid]); 326 353 xc_entry_t *p; 327 354 for (p = *pp; p; pp = &(p->next), p = p->next) { … … 339 366 { 340 367 xc_entry_t *p; 341 for (p = cache-> entries[entryslotid]; p; p = p->next) {368 for (p = cache->cached->entries[entryslotid]; p; p = p->next) { 342 369 if (xc_entry_equal_unlocked(type, entry, p TSRMLS_CC)) { 343 370 zend_bool fresh; … … 407 434 } 408 435 /* }}} */ 409 static inline void xc_cache _hit_unlocked(xc_cache_t *cacheTSRMLS_DC) /* {{{ */410 { 411 cache ->hits ++;412 413 xc_counters_inc(&cache ->hits_by_hour_cur_time414 , &cache ->hits_by_hour_cur_slot, 60 * 60415 , cache ->hits_by_hour416 , sizeof(cache ->hits_by_hour) / sizeof(cache->hits_by_hour[0])436 static inline void xc_cached_hit_unlocked(xc_cached_t *cached TSRMLS_DC) /* {{{ */ 437 { 438 cached->hits ++; 439 440 xc_counters_inc(&cached->hits_by_hour_cur_time 441 , &cached->hits_by_hour_cur_slot, 60 * 60 442 , cached->hits_by_hour 443 , sizeof(cached->hits_by_hour) / sizeof(cached->hits_by_hour[0]) 417 444 TSRMLS_CC); 418 445 419 xc_counters_inc(&cache ->hits_by_second_cur_time420 , &cache ->hits_by_second_cur_slot, 1421 , cache ->hits_by_second422 , sizeof(cache ->hits_by_second) / sizeof(cache->hits_by_second[0])446 xc_counters_inc(&cached->hits_by_second_cur_time 447 , &cached->hits_by_second_cur_slot, 1 448 , cached->hits_by_second 449 , sizeof(cached->hits_by_second) / sizeof(cached->hits_by_second[0]) 423 450 TSRMLS_CC); 424 451 } … … 434 461 435 462 for (i = 0, c = cache->hentry->size; i < c; i ++) { 436 pp = &(cache-> entries[i]);463 pp = &(cache->cached->entries[i]); 437 464 for (p = *pp; p; p = *pp) { 438 465 if (apply_func(p TSRMLS_CC)) { … … 473 500 static void xc_gc_expires_one(xc_entry_type_t type, xc_cache_t *cache, zend_ulong gc_interval, cache_apply_unlocked_func_t apply_func TSRMLS_DC) /* {{{ */ 474 501 { 475 TRACE("interval %lu, %lu %lu", (zend_ulong) XG(request_time), (zend_ulong) cache-> last_gc_expires, gc_interval);476 if (XG(request_time) >= cache-> last_gc_expires + (time_t) gc_interval) {502 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) { 477 504 ENTER_LOCK(cache) { 478 if (XG(request_time) >= cache-> last_gc_expires + (time_t) gc_interval) {479 cache-> last_gc_expires = XG(request_time);505 if (XG(request_time) >= cache->cached->last_gc_expires + (time_t) gc_interval) { 506 cache->cached->last_gc_expires = XG(request_time); 480 507 xc_entry_apply_unlocked(type, cache, apply_func TSRMLS_CC); 481 508 } … … 493 520 494 521 for (i = 0, c = xc_php_hcache.size; i < c; i ++) { 495 xc_gc_expires_one(XC_TYPE_PHP, xc_php_caches[i], xc_php_gc_interval, xc_gc_expires_php_entry_unlocked TSRMLS_CC);522 xc_gc_expires_one(XC_TYPE_PHP, &xc_php_caches[i], xc_php_gc_interval, xc_gc_expires_php_entry_unlocked TSRMLS_CC); 496 523 } 497 524 } … … 506 533 507 534 for (i = 0, c = xc_var_hcache.size; i < c; i ++) { 508 xc_gc_expires_one(XC_TYPE_VAR, xc_var_caches[i], xc_var_gc_interval, xc_gc_expires_var_entry_unlocked TSRMLS_CC);535 xc_gc_expires_one(XC_TYPE_VAR, &xc_var_caches[i], xc_var_gc_interval, xc_gc_expires_var_entry_unlocked TSRMLS_CC); 509 536 } 510 537 } … … 515 542 xc_entry_t *p, **pp; 516 543 517 pp = &cache-> deletes;544 pp = &cache->cached->deletes; 518 545 for (p = *pp; p; p = *pp) { 519 546 xc_entry_php_t *entry = (xc_entry_php_t *) p; … … 525 552 /* unlink */ 526 553 *pp = p->next; 527 cache-> deletes_count --;554 cache->cached->deletes_count --; 528 555 xc_entry_free_real_unlocked(XC_TYPE_PHP, cache, p); 529 556 } … … 536 563 static XC_CACHE_APPLY_FUNC(xc_gc_deletes_one) /* {{{ */ 537 564 { 538 if (cache-> deletes && XG(request_time) - cache->last_gc_deletes > xc_deletes_gc_interval) {565 if (cache->cached->deletes && XG(request_time) - cache->cached->last_gc_deletes > xc_deletes_gc_interval) { 539 566 ENTER_LOCK(cache) { 540 if (cache-> deletes && XG(request_time) - cache->last_gc_deletes > xc_deletes_gc_interval) {541 cache-> last_gc_deletes = XG(request_time);567 if (cache->cached->deletes && XG(request_time) - cache->cached->last_gc_deletes > xc_deletes_gc_interval) { 568 cache->cached->last_gc_deletes = XG(request_time); 542 569 xc_gc_delete_unlocked(cache TSRMLS_CC); 543 570 } … … 552 579 if (xc_php_caches) { 553 580 for (i = 0, c = xc_php_hcache.size; i < c; i ++) { 554 xc_gc_deletes_one( xc_php_caches[i] TSRMLS_CC);581 xc_gc_deletes_one(&xc_php_caches[i] TSRMLS_CC); 555 582 } 556 583 } … … 558 585 if (xc_var_caches) { 559 586 for (i = 0, c = xc_var_hcache.size; i < c; i ++) { 560 xc_gc_deletes_one( xc_var_caches[i] TSRMLS_CC);587 xc_gc_deletes_one(&xc_var_caches[i] TSRMLS_CC); 561 588 } 562 589 } … … 573 600 xc_memsize_t avail = 0; 574 601 #endif 575 xc_mem_t *mem = cache->mem;602 const xc_mem_t *mem = cache->mem; 576 603 const xc_mem_handlers_t *handlers = mem->handlers; 577 604 zend_ulong interval; 605 const xc_cached_t *cached = cache->cached; 606 578 607 if (cachetype == XC_TYPE_PHP) { 579 608 interval = xc_php_ttl ? xc_php_gc_interval : 0; … … 584 613 585 614 add_assoc_long_ex(return_value, ZEND_STRS("slots"), cache->hentry->size); 586 add_assoc_long_ex(return_value, ZEND_STRS("compiling"), cache ->compiling);587 add_assoc_long_ex(return_value, ZEND_STRS("updates"), cache ->updates);588 add_assoc_long_ex(return_value, ZEND_STRS("misses"), cache ->updates); /* deprecated */589 add_assoc_long_ex(return_value, ZEND_STRS("hits"), cache ->hits);590 add_assoc_long_ex(return_value, ZEND_STRS("clogs"), cache ->clogs);591 add_assoc_long_ex(return_value, ZEND_STRS("ooms"), cache ->ooms);592 add_assoc_long_ex(return_value, ZEND_STRS("errors"), cache ->errors);593 594 add_assoc_long_ex(return_value, ZEND_STRS("cached"), cache ->entries_count);595 add_assoc_long_ex(return_value, ZEND_STRS("deleted"), cache ->deletes_count);615 add_assoc_long_ex(return_value, ZEND_STRS("compiling"), cached->compiling); 616 add_assoc_long_ex(return_value, ZEND_STRS("updates"), cached->updates); 617 add_assoc_long_ex(return_value, ZEND_STRS("misses"), cached->updates); /* deprecated */ 618 add_assoc_long_ex(return_value, ZEND_STRS("hits"), cached->hits); 619 add_assoc_long_ex(return_value, ZEND_STRS("clogs"), cached->clogs); 620 add_assoc_long_ex(return_value, ZEND_STRS("ooms"), cached->ooms); 621 add_assoc_long_ex(return_value, ZEND_STRS("errors"), cached->errors); 622 623 add_assoc_long_ex(return_value, ZEND_STRS("cached"), cached->entries_count); 624 add_assoc_long_ex(return_value, ZEND_STRS("deleted"), cached->deletes_count); 596 625 if (interval) { 597 time_t gc = (cache ->last_gc_expires + interval) - XG(request_time);626 time_t gc = (cached->last_gc_expires + interval) - XG(request_time); 598 627 add_assoc_long_ex(return_value, ZEND_STRS("gc"), gc > 0 ? gc : 0); 599 628 } … … 603 632 MAKE_STD_ZVAL(hits); 604 633 array_init(hits); 605 for (i = 0; i < sizeof(cache ->hits_by_hour) / sizeof(cache->hits_by_hour[0]); i ++) {606 add_next_index_long(hits, (long) cache ->hits_by_hour[i]);634 for (i = 0; i < sizeof(cached->hits_by_hour) / sizeof(cached->hits_by_hour[0]); i ++) { 635 add_next_index_long(hits, (long) cached->hits_by_hour[i]); 607 636 } 608 637 add_assoc_zval_ex(return_value, ZEND_STRS("hits_by_hour"), hits); … … 610 639 MAKE_STD_ZVAL(hits); 611 640 array_init(hits); 612 for (i = 0; i < sizeof(cache ->hits_by_second) / sizeof(cache->hits_by_second[0]); i ++) {613 add_next_index_long(hits, (long) cache ->hits_by_second[i]);641 for (i = 0; i < sizeof(cached->hits_by_second) / sizeof(cached->hits_by_second[0]); i ++) { 642 add_next_index_long(hits, (long) cached->hits_by_second[i]); 614 643 } 615 644 add_assoc_zval_ex(return_value, ZEND_STRS("hits_by_second"), hits); … … 721 750 722 751 for (i = 0, c = cache->hentry->size; i < c; i ++) { 723 for (e = cache-> entries[i]; e; e = e->next) {752 for (e = cache->cached->entries[i]; e; e = e->next) { 724 753 xc_fillentry_unlocked(type, e, i, 0, list TSRMLS_CC); 725 754 } … … 729 758 ALLOC_INIT_ZVAL(list); 730 759 array_init(list); 731 for (e = cache-> deletes; e; e = e->next) {760 for (e = cache->cached->deletes; e; e = e->next) { 732 761 xc_fillentry_unlocked(XC_TYPE_PHP, e, 0, 1, list TSRMLS_CC); 733 762 } … … 817 846 /* }}} */ 818 847 819 static inline void xc_entry_unholds_real(xc_stack_t *holds, xc_cache_t * *caches, int cachecount TSRMLS_DC) /* {{{ */848 static inline void xc_entry_unholds_real(xc_stack_t *holds, xc_cache_t *caches, int cachecount TSRMLS_DC) /* {{{ */ 820 849 { 821 850 int i; … … 828 857 TRACE("holded %d items", xc_stack_count(s)); 829 858 if (xc_stack_count(s)) { 830 cache = caches[i];859 cache = &caches[i]; 831 860 ENTER_LOCK(cache) { 832 861 while (xc_stack_count(s)) { … … 1024 1053 *entry_resolve_path_data->stored_entry = (xc_entry_php_t *) xc_entry_find_unlocked( 1025 1054 XC_TYPE_PHP 1026 , xc_php_caches[compiler->entry_hash.cacheid]1055 , &xc_php_caches[compiler->entry_hash.cacheid] 1027 1056 , compiler->entry_hash.entryslotid 1028 1057 , (xc_entry_t *) &compiler->new_entry … … 1889 1918 xc_compiler_t *compiler = sandboxed_compiler->compiler; 1890 1919 zend_bool catched = 0; 1891 xc_cache_t *cache = xc_php_caches[compiler->entry_hash.cacheid];1920 xc_cache_t *cache = &xc_php_caches[compiler->entry_hash.cacheid]; 1892 1921 xc_entry_php_t *stored_entry; 1893 1922 xc_entry_data_php_t *stored_php; … … 1950 1979 } 1951 1980 1952 cache->c ompiling = 0;1981 cache->cached->compiling = 0; 1953 1982 xc_free_php(&compiler->new_php TSRMLS_CC); 1954 1983 … … 1975 2004 xc_free_php(&compiler->new_php TSRMLS_CC); 1976 2005 1977 cache->c ompiling = 0;2006 cache->cached->compiling = 0; 1978 2007 if (catched) { 1979 cache-> errors ++;2008 cache->cached->errors ++; 1980 2009 zend_bailout(); 1981 2010 } … … 2016 2045 zend_bool catched = 0; 2017 2046 zend_op_array *op_array; 2018 xc_cache_t *cache = xc_php_caches[compiler->entry_hash.cacheid];2047 xc_cache_t *cache = &xc_php_caches[compiler->entry_hash.cacheid]; 2019 2048 xc_sandboxed_compiler_t sandboxed_compiler; 2020 2049 2021 2050 /* stale clogs precheck */ 2022 if (XG(request_time) - cache->c ompiling < 30) {2023 cache->c logs ++;2051 if (XG(request_time) - cache->cached->compiling < 30) { 2052 cache->cached->clogs ++; 2024 2053 return old_compile_file(h, type TSRMLS_CC); 2025 2054 } … … 2047 2076 2048 2077 if (stored_entry) { 2049 xc_cache _hit_unlocked(cacheTSRMLS_CC);2078 xc_cached_hit_unlocked(cache->cached TSRMLS_CC); 2050 2079 2051 2080 TRACE(" hit %d:%s, holding", compiler->new_entry.file_inode, stored_entry->entry.name.str.val); … … 2062 2091 } 2063 2092 2064 stored_php = xc_php_find_unlocked(cache , &compiler->new_php TSRMLS_CC);2093 stored_php = xc_php_find_unlocked(cache->cached, &compiler->new_php TSRMLS_CC); 2065 2094 2066 2095 if (stored_php) { … … 2079 2108 } 2080 2109 2081 if (XG(request_time) - cache->c ompiling < 30) {2110 if (XG(request_time) - cache->cached->compiling < 30) { 2082 2111 TRACE("%s", "miss php, but compiling"); 2083 cache->c logs ++;2112 cache->cached->clogs ++; 2084 2113 gaveup = 1; 2085 2114 break; … … 2087 2116 2088 2117 TRACE("%s", "miss php, going to compile"); 2089 cache->c ompiling = XG(request_time);2118 cache->cached->compiling = XG(request_time); 2090 2119 } LEAVE_LOCK_EX(cache); 2091 2120 2092 2121 if (catched) { 2093 cache->c ompiling = 0;2122 cache->cached->compiling = 0; 2094 2123 zend_bailout(); 2095 2124 } … … 2172 2201 if (xc_php_caches) { 2173 2202 for (i = 0; i < xc_php_hcache.size; i ++) { 2174 shm = xc_php_caches[i] ->shm;2203 shm = xc_php_caches[i].shm; 2175 2204 if (shm->handlers->is_readwrite(shm, p)) { 2176 2205 return 1; … … 2181 2210 if (xc_var_caches) { 2182 2211 for (i = 0; i < xc_var_hcache.size; i ++) { 2183 shm = xc_var_caches[i] ->shm;2212 shm = xc_var_caches[i].shm; 2184 2213 if (shm->handlers->is_readwrite(shm, p)) { 2185 2214 return 1; … … 2197 2226 if (xc_php_caches) { 2198 2227 for (i = 0; i < xc_php_hcache.size; i ++) { 2199 shm = xc_php_caches[i] ->shm;2228 shm = xc_php_caches[i].shm; 2200 2229 if (shm->handlers->is_readonly(shm, p)) { 2201 2230 return 1; … … 2206 2235 if (xc_var_caches) { 2207 2236 for (i = 0; i < xc_var_hcache.size; i ++) { 2208 shm = xc_var_caches[i] ->shm;2237 shm = xc_var_caches[i].shm; 2209 2238 if (shm->handlers->is_readonly(shm, p)) { 2210 2239 return 1; … … 2255 2284 } 2256 2285 /* }}} */ 2257 static xc_shm_t *xc_cache_destroy(xc_cache_t * *caches, xc_hash_t *hcache) /* {{{ */2286 static xc_shm_t *xc_cache_destroy(xc_cache_t *caches, xc_hash_t *hcache) /* {{{ */ 2258 2287 { 2259 2288 size_t i; 2260 xc_cache_t *cache;2261 2289 xc_shm_t *shm = NULL; 2262 2290 2263 if (!caches) { 2264 return shm; 2265 } 2291 assert(caches); 2266 2292 2267 2293 for (i = 0; i < hcache->size; i ++) { 2268 cache =caches[i];2294 xc_cache_t *cache = &caches[i]; 2269 2295 if (cache) { 2270 2296 if (cache->lck) { … … 2285 2311 } 2286 2312 /* }}} */ 2287 static xc_cache_t * *xc_cache_init(xc_shm_t *shm, xc_hash_t *hcache, xc_hash_t *hentry, xc_hash_t *hphp, xc_shmsize_t shmsize) /* {{{ */2288 { 2289 xc_cache_t * *caches = NULL, *cache;2313 static xc_cache_t *xc_cache_init(xc_shm_t *shm, xc_hash_t *hcache, xc_hash_t *hentry, xc_hash_t *hphp, xc_shmsize_t shmsize) /* {{{ */ 2314 { 2315 xc_cache_t *caches = NULL; 2290 2316 xc_mem_t *mem; 2291 2317 time_t now = time(NULL); … … 2306 2332 } 2307 2333 2308 CHECK(caches = calloc(hcache->size, sizeof(xc_cache_t *)), "caches OOM");2334 CHECK(caches = calloc(hcache->size, sizeof(xc_cache_t)), "caches OOM"); 2309 2335 2310 2336 for (i = 0; i < hcache->size; i ++) { 2311 CHECK(mem = shm->handlers->meminit(shm, memsize), "Failed init memory allocator"); 2312 CHECK(cache = mem->handlers->calloc(mem, 1, sizeof(xc_cache_t)), "cache OOM"); 2313 CHECK(cache->entries = mem->handlers->calloc(mem, hentry->size, sizeof(xc_entry_t*)), "entries OOM"); 2337 xc_cache_t *cache = &caches[i]; 2338 CHECK(mem = shm->handlers->meminit(shm, memsize), "Failed init memory allocator"); 2339 CHECK(cache->cached = mem->handlers->calloc(mem, 1, sizeof(xc_cached_t)), "cache OOM"); 2340 CHECK(cache->cached->entries = mem->handlers->calloc(mem, hentry->size, sizeof(xc_entry_t*)), "entries OOM"); 2314 2341 if (hphp) { 2315 CHECK(cache-> phps= mem->handlers->calloc(mem, hphp->size, sizeof(xc_entry_data_php_t*)), "phps OOM");2316 } 2317 CHECK(cache->lck = xc_lock_init(NULL), "can't create lock");2342 CHECK(cache->cached->phps = mem->handlers->calloc(mem, hphp->size, sizeof(xc_entry_data_php_t*)), "phps OOM"); 2343 } 2344 CHECK(cache->lck = xc_lock_init(NULL), "can't create lock"); 2318 2345 2319 2346 cache->hcache = hcache; … … 2323 2350 cache->mem = mem; 2324 2351 cache->cacheid = i; 2325 cache->last_gc_deletes = now; 2326 cache->last_gc_expires = now; 2327 caches[i] = cache; 2352 cache->cached->last_gc_deletes = now; 2353 cache->cached->last_gc_expires = now; 2328 2354 } 2329 2355 return caches; … … 2577 2603 ENTER_LOCK(cache) { 2578 2604 for (entryslotid = 0, c = cache->hentry->size; entryslotid < c; entryslotid ++) { 2579 for (e = cache-> entries[entryslotid]; e; e = next) {2605 for (e = cache->cached->entries[entryslotid]; e; e = next) { 2580 2606 next = e->next; 2581 2607 xc_entry_remove_unlocked(type, cache, entryslotid, e TSRMLS_CC); 2582 2608 } 2583 cache-> entries[entryslotid] = NULL;2609 cache->cached->entries[entryslotid] = NULL; 2584 2610 } 2585 2611 } LEAVE_LOCK(cache); … … 2591 2617 long type; 2592 2618 int size; 2593 xc_cache_t * *caches, *cache;2619 xc_cache_t *caches, *cache; 2594 2620 long id = 0; 2595 2621 … … 2648 2674 array_init(return_value); 2649 2675 2650 cache = caches[id];2676 cache = &caches[id]; 2651 2677 ENTER_LOCK(cache) { 2652 2678 if (optype == XC_OP_INFO) { … … 2667 2693 if (id == -1) { 2668 2694 for (id = 0; id < size; ++id) { 2669 xc_clear(type, caches[id] TSRMLS_CC);2695 xc_clear(type, &caches[id] TSRMLS_CC); 2670 2696 } 2671 2697 } 2672 2698 else { 2673 xc_clear(type, caches[id] TSRMLS_CC);2699 xc_clear(type, &caches[id] TSRMLS_CC); 2674 2700 } 2675 2701 … … 2763 2789 } 2764 2790 xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC); 2765 cache = xc_var_caches[entry_hash.cacheid];2791 cache = &xc_var_caches[entry_hash.cacheid]; 2766 2792 2767 2793 ENTER_LOCK(cache) { … … 2770 2796 /* return */ 2771 2797 xc_processor_restore_zval(return_value, stored_entry_var->value, stored_entry_var->have_references TSRMLS_CC); 2772 xc_cache _hit_unlocked(cacheTSRMLS_CC);2798 xc_cached_hit_unlocked(cache->cached TSRMLS_CC); 2773 2799 } 2774 2800 else { … … 2809 2835 2810 2836 xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC); 2811 cache = xc_var_caches[entry_hash.cacheid];2837 cache = &xc_var_caches[entry_hash.cacheid]; 2812 2838 2813 2839 ENTER_LOCK(cache) { … … 2839 2865 } 2840 2866 xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC); 2841 cache = xc_var_caches[entry_hash.cacheid];2867 cache = &xc_var_caches[entry_hash.cacheid]; 2842 2868 2843 2869 ENTER_LOCK(cache) { 2844 2870 stored_entry_var = (xc_entry_var_t *) xc_entry_find_unlocked(XC_TYPE_VAR, cache, entry_hash.entryslotid, (xc_entry_t *) &entry_var TSRMLS_CC); 2845 2871 if (stored_entry_var) { 2846 xc_cache _hit_unlocked(cacheTSRMLS_CC);2872 xc_cached_hit_unlocked(cache->cached TSRMLS_CC); 2847 2873 RETVAL_TRUE; 2848 2874 /* return */ … … 2873 2899 } 2874 2900 xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC); 2875 cache = xc_var_caches[entry_hash.cacheid];2901 cache = &xc_var_caches[entry_hash.cacheid]; 2876 2902 2877 2903 ENTER_LOCK(cache) { … … 2904 2930 2905 2931 for (i = 0, iend = xc_var_hcache.size; i < iend; i ++) { 2906 xc_cache_t *cache = xc_var_caches[i];2932 xc_cache_t *cache = &xc_var_caches[i]; 2907 2933 ENTER_LOCK(cache) { 2908 2934 int entryslotid, jend; 2909 2935 for (entryslotid = 0, jend = cache->hentry->size; entryslotid < jend; entryslotid ++) { 2910 2936 xc_entry_t *entry, *next; 2911 for (entry = cache-> entries[entryslotid]; entry; entry = next) {2937 for (entry = cache->cached->entries[entryslotid]; entry; entry = next) { 2912 2938 next = entry->next; 2913 2939 if (xc_entry_has_prefix_unlocked(XC_TYPE_VAR, entry, prefix)) { … … 2946 2972 2947 2973 xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC); 2948 cache = xc_var_caches[entry_hash.cacheid];2974 cache = &xc_var_caches[entry_hash.cacheid]; 2949 2975 2950 2976 ENTER_LOCK(cache) { … … 2964 2990 zv = (zval *) cache->shm->handlers->to_readwrite(cache->shm, (char *) stored_entry_var->value); 2965 2991 Z_LVAL_P(zv) = value; 2966 ++cache-> updates;2992 ++cache->cached->updates; 2967 2993 break; /* leave lock */ 2968 2994 } … … 3208 3234 if (ext) { 3209 3235 /* zend_optimizer.optimization_level>0 is not compatible with other cacher, disabling */ 3236 #if 0 3210 3237 ext->op_array_handler = NULL; 3238 #endif 3211 3239 } 3212 3240 /* cache if there's an op_array_ctor */
Note: See TracChangeset
for help on using the changeset viewer.

