Changeset 851
- Timestamp:
- 2012-03-27T18:07:50+02:00 (14 months ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
admin/xcache.tpl.php (modified) (2 diffs)
-
processor/head.m4 (modified) (7 diffs)
-
processor/main.m4 (modified) (1 diff)
-
processor/processor.m4 (modified) (9 diffs)
-
xcache.c (modified) (61 diffs)
-
xcache.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/xcache.tpl.php
r689 r851 212 212 $size = size($entry['size']); 213 213 if ($isphp) { 214 $ sourcesize = size($entry['sourcesize']);214 $file_size = size($entry['file_size']); 215 215 $phprefcount = number_format($entry['phprefcount']); 216 216 } … … 246 246 echo <<<ENTRY 247 247 <td int="{$entry['phprefcount']}">{$phprefcount}</td> 248 <td int="{$entry[' sourcesize']}">{$sourcesize}</td>248 <td int="{$entry['file_size']}">{$file_size}</td> 249 249 <td int="{$entry['mtime']}">{$mtime}</td> 250 250 ENTRY; 251 if (isset($entry[' inode'])) {251 if (isset($entry['file_inode'])) { 252 252 echo <<<ENTRY 253 <td int="{$entry[' device']}">{$entry['device']}</td>254 <td int="{$entry[' inode']}">{$entry['inode']}</td>253 <td int="{$entry['file_device']}">{$entry['file_device']}</td> 254 <td int="{$entry['file_inode']}">{$entry['file_inode']}</td> 255 255 ENTRY; 256 256 } -
trunk/processor/head.m4
r846 r851 82 82 zend_bool reference; /* enable if to deal with reference */ 83 83 zend_bool have_references; 84 const xc_entry_ t *entry_src;85 const xc_entry_ t *entry_dst;84 const xc_entry_php_t *entry_php_src; 85 const xc_entry_php_t *entry_php_dst; 86 86 const xc_entry_data_php_t *php_src; 87 87 const xc_entry_data_php_t *php_dst; … … 396 396 memset(&processor, 0, sizeof(processor)); 397 397 processor.reference = 1; 398 processor.cache = src-> cache;398 processor.cache = src->ifelse(`$1', `xc_entry_php_t', entry.)cache; 399 399 400 400 IFASSERT(`xc_stack_init(&processor.allocsizes);') … … 416 416 zend_hash_destroy(&processor.strings); 417 417 } 418 src->size = processor.size; 419 ifelse(`$1', `xc_entry_t', ` 420 src->data.var->have_references = processor.have_references; 421 ', ` 422 src->have_references = processor.have_references; 423 ') 418 src->ifelse(`$1', `xc_entry_php_t', entry.)size = processor.size; 419 ifelse( 420 `$1', `xc_entry_t', `src->data.var.have_references = processor.have_references;', 421 `$1', `xc_entry_data_php_t', `src->have_references = processor.have_references;' 422 ) 424 423 425 424 IFASSERT(`xc_stack_reverse(&processor.allocsizes);') … … 469 468 ') 470 469 DEFINE_STORE_API(`xc_entry_t') 470 DEFINE_STORE_API(`xc_entry_php_t') 471 471 DEFINE_STORE_API(`xc_entry_data_php_t') 472 /* export: xc_entry_ t *xc_processor_restore_xc_entry_t(xc_entry_t *dst, const xc_entry_t *src TSRMLS_DC); :export {{{ */473 xc_entry_ t *xc_processor_restore_xc_entry_t(xc_entry_t *dst, const xc_entry_t *src TSRMLS_DC) {472 /* export: xc_entry_php_t *xc_processor_restore_xc_entry_php_t(xc_entry_php_t *dst, const xc_entry_php_t *src TSRMLS_DC); :export {{{ */ 473 xc_entry_php_t *xc_processor_restore_xc_entry_php_t(xc_entry_php_t *dst, const xc_entry_php_t *src TSRMLS_DC) { 474 474 xc_processor_t processor; 475 475 476 476 memset(&processor, 0, sizeof(processor)); 477 xc_restore_xc_entry_ t(&processor, dst, src TSRMLS_CC);477 xc_restore_xc_entry_php_t(&processor, dst, src TSRMLS_CC); 478 478 479 479 return dst; 480 480 } 481 481 /* }}} */ 482 /* export: xc_entry_data_php_t *xc_processor_restore_xc_entry_data_php_t(const xc_entry_ t *xce, xc_entry_data_php_t *dst, const xc_entry_data_php_t *src, zend_bool readonly_protection TSRMLS_DC); :export {{{ */483 xc_entry_data_php_t *xc_processor_restore_xc_entry_data_php_t(const xc_entry_ t *xce, xc_entry_data_php_t *dst, const xc_entry_data_php_t *src, zend_bool readonly_protection TSRMLS_DC) {482 /* export: xc_entry_data_php_t *xc_processor_restore_xc_entry_data_php_t(const xc_entry_php_t *xce, xc_entry_data_php_t *dst, const xc_entry_data_php_t *src, zend_bool readonly_protection TSRMLS_DC); :export {{{ */ 483 xc_entry_data_php_t *xc_processor_restore_xc_entry_data_php_t(const xc_entry_php_t *xce, xc_entry_data_php_t *dst, const xc_entry_data_php_t *src, zend_bool readonly_protection TSRMLS_DC) { 484 484 xc_processor_t processor; 485 485 … … 490 490 processor.reference = 1; 491 491 } 492 processor.entry_ src = xce;492 processor.entry_php_src = xce; 493 493 494 494 if (processor.reference) { … … 499 499 zend_hash_destroy(&processor.zvalptrs); 500 500 } 501 return dst; 502 } 503 /* }}} */ 504 /* export: xc_entry_t *xc_processor_restore_xc_entry_t(xc_entry_t *dst, const xc_entry_t *src TSRMLS_DC); :export {{{ */ 505 xc_entry_t *xc_processor_restore_xc_entry_t(xc_entry_t *dst, const xc_entry_t *src TSRMLS_DC) { 506 xc_processor_t processor; 507 508 memset(&processor, 0, sizeof(processor)); 509 xc_restore_xc_entry_t(&processor, dst, src TSRMLS_CC); 510 501 511 return dst; 502 512 } … … 522 532 } 523 533 /* }}} */ 524 /* export: void xc_dprint(xc_entry_ t *src, int indent TSRMLS_DC); :export {{{ */534 /* export: void xc_dprint(xc_entry_php_t *src, int indent TSRMLS_DC); :export {{{ */ 525 535 #ifdef HAVE_XCACHE_DPRINT 526 void xc_dprint(xc_entry_ t *src, int indent TSRMLS_DC) {536 void xc_dprint(xc_entry_php_t *src, int indent TSRMLS_DC) { 527 537 IFDPRINT(`INDENT()`'fprintf(stderr, "xc_entry_t:src");') 528 538 xc_dprint_xc_entry_t(src, indent TSRMLS_CC); -
trunk/processor/main.m4
r844 r851 253 253 EXPORT(`xc_funcinfo_t') 254 254 EXPORT(`xc_entry_t') 255 EXPORT(`xc_entry_php_t') 255 256 EXPORT(`xc_entry_data_php_t') 256 257 EXPORT(`zval') -
trunk/processor/processor.m4
r846 r851 431 431 # ifdef ZEND_ENGINE_2_4 432 432 DISABLECHECK(` 433 IFRESTORE(`dst->info.user.filename = processor->entry_ src->filepath;', `PROC_STRING(info.user.filename)')433 IFRESTORE(`dst->info.user.filename = processor->entry_php_src->filepath;', `PROC_STRING(info.user.filename)') 434 434 PROCESS(zend_uint, info.user.line_start) 435 435 PROCESS(zend_uint, info.user.line_end) … … 439 439 DONE(info) 440 440 # else 441 IFRESTORE(`dst->filename = processor->entry_ src->filepath;DONE(filename)', `PROC_STRING(filename)')441 IFRESTORE(`dst->filename = processor->entry_php_src->filepath;DONE(filename)', `PROC_STRING(filename)') 442 442 PROCESS(zend_uint, line_start) 443 443 PROCESS(zend_uint, line_end) … … 709 709 gc_arg_info = 1; 710 710 #endif 711 dst->filename = processor->entry_ src->filepath;711 dst->filename = processor->entry_php_src->filepath; 712 712 #ifdef ZEND_ENGINE_2_4 713 713 if (src->literals /* || op_array_info->literalsinfo_cnt */) { … … 886 886 #endif 887 887 888 IFRESTORE(`dst->filename = processor->entry_ src->filepath;DONE(filename)', `PROC_STRING(filename)')888 IFRESTORE(`dst->filename = processor->entry_php_src->filepath;DONE(filename)', `PROC_STRING(filename)') 889 889 #ifdef IS_UNICODE 890 890 IFRESTORE(` … … 914 914 #endif 915 915 } while (0); 916 IFRESTORE(`xc_fix_op_array_info(processor->entry_ src, processor->php_src, dst, shallow_copy, op_array_info TSRMLS_CC);')916 IFRESTORE(`xc_fix_op_array_info(processor->entry_php_src, processor->php_src, dst, shallow_copy, op_array_info TSRMLS_CC);') 917 917 918 918 #ifdef ZEND_ENGINE_2 … … 1074 1074 PROCESS(zend_ulong, refcount) 1075 1075 1076 PROCESS(size_t, sourcesize)1076 PROCESS(size_t, file_size) 1077 1077 PROCESS(zend_ulong, hits) 1078 1078 PROCESS(size_t, size) … … 1127 1127 dnl }}} 1128 1128 DEF_STRUCT_P_FUNC(`xc_entry_t', , `dnl {{{ 1129 PROCESS(xc_hash_value_t, hvalue) 1130 /* skip */ 1131 DONE(next) 1132 COPY(cache) 1129 1133 PROCESS(xc_entry_type_t, type) 1130 1134 PROCESS(size_t, size) 1131 1132 PROCESS(xc_hash_value_t, hvalue)1133 COPY(cache)1134 /* skip */1135 DONE(next)1136 1137 IFSTORE(`dst->refcount = 0; DONE(refcount)', `PROCESS(long, refcount)')1138 1135 1139 1136 PROCESS(time_t, ctime) … … 1176 1173 1177 1174 case XC_TYPE_VAR: 1178 STRUCT _P(xc_entry_data_var_t, data.var)1175 STRUCT(xc_entry_data_var_t, data.var) 1179 1176 break; 1180 1177 … … 1185 1182 DONE(data) 1186 1183 dnl }}} 1187 PROCESS(time_t, mtime) 1184 ') 1185 dnl }}} 1186 DEF_STRUCT_P_FUNC(`xc_entry_php_t', , `dnl {{{ 1187 STRUCT(xc_entry_t, entry) 1188 1189 IFSTORE(`dst->refcount = 0; DONE(refcount)', `PROCESS(long, refcount)') 1190 PROCESS(time_t, file_mtime) 1188 1191 #ifdef HAVE_INODE 1189 PROCESS(int, device)1190 PROCESS(int, inode)1191 #endif 1192 1193 if (src-> type == XC_TYPE_PHP) {1192 PROCESS(int, file_device) 1193 PROCESS(int, file_inode) 1194 #endif 1195 1196 if (src->entry.type == XC_TYPE_PHP) { 1194 1197 PROCESS(int, filepath_len) 1195 1198 IFRESTORE(`COPY(filepath)', `PROC_STRING_L(filepath, filepath_len)') -
trunk/xcache.c
r848 r851 145 145 { 146 146 xc_entry_data_php_t *p; 147 for (p = php->cache->phps[php->hvalue]; p; p = p->next) {147 for (p = php->cache->phps[php->hvalue]; p; p = (xc_entry_data_php_t *) p->next) { 148 148 if (memcmp(&php->md5.digest, &p->md5.digest, sizeof(php->md5.digest)) == 0) { 149 149 p->hits ++; … … 182 182 /* }}} */ 183 183 184 static inline int xc_entry_equal_dmz( xc_entry_t *a, xc_entry_t *b) /* {{{ */184 static inline int xc_entry_equal_dmz(const xc_entry_t *entry1, const xc_entry_t *entry2) /* {{{ */ 185 185 { 186 186 /* this function isn't required but can be in dmz */ 187 187 188 if ( a->type != b->type) {188 if (entry1->type != entry2->type) { 189 189 return 0; 190 190 } 191 switch ( a->type) {191 switch (entry1->type) { 192 192 case XC_TYPE_PHP: 193 193 #ifdef HAVE_INODE 194 do { 195 if (a->inode) { 196 return a->inode == b->inode 197 && a->device == b->device; 194 { 195 const xc_entry_php_t *php_entry1 = (const xc_entry_php_t *) entry1; 196 const xc_entry_php_t *php_entry2 = (const xc_entry_php_t *) entry2; 197 if (php_entry1->file_inode) { 198 return php_entry1->file_inode == php_entry2->file_inode 199 && php_entry1->file_device == php_entry2->file_device; 198 200 } 199 } while(0);201 } 200 202 #endif 201 203 /* fall */ … … 204 206 do { 205 207 #ifdef IS_UNICODE 206 if ( a->name_type == IS_UNICODE) {207 if ( a->name.ustr.len != b->name.ustr.len) {208 if (entry1->name_type == IS_UNICODE) { 209 if (entry1->name.ustr.len != entry2->name.ustr.len) { 208 210 return 0; 209 211 } 210 return memcmp( a->name.ustr.val, b->name.ustr.val, (a->name.ustr.len + 1) * sizeof(UChar)) == 0;212 return memcmp(entry1->name.ustr.val, entry2->name.ustr.val, (entry1->name.ustr.len + 1) * sizeof(UChar)) == 0; 211 213 } 212 214 #endif 213 if ( a->name.str.len != b->name.str.len) {215 if (entry1->name.str.len != entry2->name.str.len) { 214 216 return 0; 215 217 } 216 return memcmp( a->name.str.val, b->name.str.val, a->name.str.len + 1) == 0;218 return memcmp(entry1->name.str.val, entry2->name.str.val, entry1->name.str.len + 1) == 0; 217 219 218 220 } while(0); … … 275 277 xce->ctime = XG(request_time); 276 278 xce->atime = XG(request_time); 277 stored_xce = xc_processor_store_xc_entry_t(xce TSRMLS_CC); 279 stored_xce = xce->type == XC_TYPE_PHP 280 ? (xc_entry_t *) xc_processor_store_xc_entry_php_t((xc_entry_php_t *) xce TSRMLS_CC) 281 : xc_processor_store_xc_entry_t(xce TSRMLS_CC); 278 282 if (stored_xce) { 279 283 xc_entry_add_dmz(stored_xce); … … 286 290 } 287 291 /* }}} */ 292 static xc_entry_php_t *xc_entry_php_store_dmz(xc_entry_php_t *xce TSRMLS_DC) /* {{{ */ 293 { 294 return (xc_entry_php_t *) xc_entry_store_dmz((xc_entry_t *) xce TSRMLS_CC); 295 } 296 /* }}} */ 288 297 static void xc_entry_free_real_dmz(volatile xc_entry_t *xce) /* {{{ */ 289 298 { … … 297 306 { 298 307 xce->cache->entries_count --; 299 if ( xce->refcount== 0) {308 if ((xce->type == XC_TYPE_PHP ? ((xc_entry_php_t *) xce)->refcount : 0) == 0) { 300 309 xc_entry_free_real_dmz(xce); 301 310 } … … 329 338 for (p = xce->cache->entries[xce->hvalue]; p; p = p->next) { 330 339 if (xc_entry_equal_dmz(xce, p)) { 331 if (p->type == XC_TYPE_VAR || /* PHP */ (p->mtime == xce->mtime && p->data.php->sourcesize == xce->data.php->sourcesize)) { 340 zend_bool fresh; 341 switch (p->type) { 342 case XC_TYPE_PHP: 343 { 344 xc_entry_php_t *p_php = (xc_entry_php_t *) p; 345 xc_entry_php_t *xce_php = (xc_entry_php_t *) xce; 346 fresh = p_php->file_mtime == xce_php->file_mtime && p->data.php->file_size == xce->data.php->file_size; 347 break; 348 } 349 350 case XC_TYPE_VAR: 351 fresh = 1; 352 break; 353 354 default: 355 assert(0); 356 } 357 358 if (fresh) { 332 359 p->hits ++; 333 360 p->atime = XG(request_time); 334 361 return p; 335 362 } 336 else { 337 xc_entry_remove_dmz(p TSRMLS_CC); 338 return NULL; 339 } 363 364 xc_entry_remove_dmz(p TSRMLS_CC); 365 return NULL; 340 366 } 341 367 } … … 343 369 } 344 370 /* }}} */ 345 static void xc_entry_hold_php_dmz(xc_entry_ t *xce TSRMLS_DC) /* {{{ */346 { 347 TRACE("hold %s", xce-> name.str.val);371 static void xc_entry_hold_php_dmz(xc_entry_php_t *xce TSRMLS_DC) /* {{{ */ 372 { 373 TRACE("hold %s", xce->entry.name.str.val); 348 374 xce->refcount ++; 349 xc_stack_push(&XG(php_holds)[xce-> cache->cacheid], (void *)xce);375 xc_stack_push(&XG(php_holds)[xce->entry.cache->cacheid], (void *)xce); 350 376 } 351 377 /* }}} */ … … 500 526 pp = &cache->deletes; 501 527 for (p = *pp; p; p = *pp) { 528 xc_entry_php_t *entry = (xc_entry_php_t *) p; 502 529 if (XG(request_time) - p->dtime > 3600) { 503 p->refcount = 0;530 entry->refcount = 0; 504 531 /* issue warning here */ 505 532 } 506 if ( p->refcount == 0) {533 if (entry->refcount == 0) { 507 534 /* unlink */ 508 535 *pp = p->next; … … 622 649 } 623 650 /* }}} */ 624 static void xc_fillentry_dmz( xc_entry_t *entry, int del, zval *list TSRMLS_DC) /* {{{ */651 static void xc_fillentry_dmz(const xc_entry_t *entry, int del, zval *list TSRMLS_DC) /* {{{ */ 625 652 { 626 653 zval* ei; 627 xc_entry_data_php_t *php; 628 xc_entry_data_var_t *var; 654 const xc_entry_data_php_t *php; 655 const xc_entry_data_var_t *var; 656 xc_entry_php_t *entry_php = (xc_entry_php_t *) entry; 629 657 630 658 ALLOC_INIT_ZVAL(ei); 631 659 array_init(ei); 632 660 633 add_assoc_long_ex(ei, ZEND_STRS("refcount"), entry ->refcount);661 add_assoc_long_ex(ei, ZEND_STRS("refcount"), entry_php->refcount); 634 662 add_assoc_long_ex(ei, ZEND_STRS("hits"), entry->hits); 635 663 add_assoc_long_ex(ei, ZEND_STRS("ctime"), entry->ctime); … … 664 692 add_assoc_long_ex(ei, ZEND_STRS("size"), entry->size + php->size); 665 693 add_assoc_long_ex(ei, ZEND_STRS("phprefcount"), php->refcount); 666 add_assoc_long_ex(ei, ZEND_STRS(" sourcesize"), php->sourcesize);694 add_assoc_long_ex(ei, ZEND_STRS("file_size"), php->file_size); 667 695 #ifdef HAVE_INODE 668 add_assoc_long_ex(ei, ZEND_STRS(" device"), entry->device);669 add_assoc_long_ex(ei, ZEND_STRS(" inode"), entry->inode);670 #endif 671 add_assoc_long_ex(ei, ZEND_STRS(" mtime"), entry->mtime);696 add_assoc_long_ex(ei, ZEND_STRS("file_device"), entry_php->file_device); 697 add_assoc_long_ex(ei, ZEND_STRS("file_inode"), entry_php->file_inode); 698 #endif 699 add_assoc_long_ex(ei, ZEND_STRS("file_mtime"), entry_php->file_mtime); 672 700 673 701 #ifdef HAVE_XCACHE_CONSTANT … … 682 710 683 711 case XC_TYPE_VAR: 684 var = entry->data.var;712 var = &entry->data.var; 685 713 add_assoc_long_ex(ei, ZEND_STRS("size"), entry->size); 686 714 break; … … 718 746 /* }}} */ 719 747 720 static zend_op_array *xc_entry_install(xc_entry_ t *xce, zend_file_handle *h TSRMLS_DC) /* {{{ */748 static zend_op_array *xc_entry_install(xc_entry_php_t *xce, zend_file_handle *h TSRMLS_DC) /* {{{ */ 721 749 { 722 750 zend_uint i; 723 xc_entry_data_php_t *p = xce-> data.php;751 xc_entry_data_php_t *p = xce->entry.data.php; 724 752 zend_op_array *old_active_op_array = CG(active_op_array); 725 753 #ifndef ZEND_ENGINE_2 … … 735 763 for (i = 0; i < p->constinfo_cnt; i ++) { 736 764 xc_constinfo_t *ci = &p->constinfos[i]; 737 xc_install_constant(xce-> name.str.val, &ci->constant,765 xc_install_constant(xce->entry.name.str.val, &ci->constant, 738 766 UNISW(0, ci->type), ci->key, ci->key_size, ci->h TSRMLS_CC); 739 767 } … … 743 771 for (i = 0; i < p->funcinfo_cnt; i ++) { 744 772 xc_funcinfo_t *fi = &p->funcinfos[i]; 745 xc_install_function(xce-> name.str.val, &fi->func,773 xc_install_function(xce->entry.name.str.val, &fi->func, 746 774 UNISW(0, fi->type), fi->key, fi->key_size, fi->h TSRMLS_CC); 747 775 } … … 761 789 #endif 762 790 #ifdef ZEND_COMPILE_DELAYED_BINDING 763 xc_install_class(xce-> name.str.val, &ci->cest, -1,791 xc_install_class(xce->entry.name.str.val, &ci->cest, -1, 764 792 UNISW(0, ci->type), ci->key, ci->key_size, ci->h TSRMLS_CC); 765 793 #else 766 xc_install_class(xce-> name.str.val, &ci->cest, ci->oplineno,794 xc_install_class(xce->entry.name.str.val, &ci->cest, ci->oplineno, 767 795 UNISW(0, ci->type), ci->key, ci->key_size, ci->h TSRMLS_CC); 768 796 #endif … … 787 815 788 816 i = 1; 789 zend_hash_add(&EG(included_files), xce-> name.str.val, xce->name.str.len+1, (void *)&i, sizeof(int), NULL);817 zend_hash_add(&EG(included_files), xce->entry.name.str.val, xce->entry.name.str.len+1, (void *)&i, sizeof(int), NULL); 790 818 if (h) { 791 819 zend_llist_add_element(&CG(open_files), h); … … 816 844 xce = (xc_entry_t*) xc_stack_pop(s); 817 845 TRACE("unhold %s", xce->name.str.val); 818 xce->refcount --;819 assert( xce->refcount >= 0);846 ((xc_entry_php_t *) xce)->refcount ++; 847 assert(((xc_entry_php_t *) xce)->refcount >= 0); 820 848 } 821 849 } LEAVE_LOCK(cache); … … 885 913 /* }}} */ 886 914 915 #if 0 /* {{{ note about php hashing */ 916 the folling note is written in the form of "got = from" 917 918 TODO: open_basedir 919 920 opened_path = stat || zend_compile_file 921 922 phphashid = inode ? inode : hash(basename) 923 md5key = md5(relativepath) 924 md5hashid = hash(md5key) 925 cachehashid = multislot ? hash(basename) : hash(phphashid) 926 927 cached = phphashid -> md5key -> cachedmd5info -> cachedphp 928 cachedphp = [phphashid, fullpath] 929 restoredphp = [fullpath, phphashid] 930 931 #endif /* }}} */ 932 887 933 #define HASH(i) (i) 888 934 #define HASH_ZSTR_L(t, s, l) HASH(zend_u_inline_hash_func((t), (s), ((l) + 1) * sizeof(UChar))) … … 907 953 } 908 954 /* }}} */ 909 #define xc_entry_hash_var xc_entry_hash_name 910 static inline xc_hash_value_t xc_entry_hash_php(xc_entry_t *xce TSRMLS_DC) /* {{{ */ 911 { 912 #ifdef HAVE_INODE 913 if (xce->inode) { 914 return HASH(xce->device + xce->inode); 915 } 916 #endif 917 return xc_entry_hash_name(xce TSRMLS_CC); 918 } 919 /* }}} */ 920 static inline xc_hash_value_t xc_entry_hash_php_basename(xc_entry_t *xce TSRMLS_DC) /* {{{ */ 955 static inline xc_hash_value_t xc_entry_hash_php_basename(xc_entry_php_t *xce TSRMLS_DC) /* {{{ */ 921 956 { 922 957 #ifdef IS_UNICODE 923 if (UG(unicode) && xce-> name_type == IS_UNICODE) {958 if (UG(unicode) && xce->entry.name_type == IS_UNICODE) { 924 959 zstr basename; 925 960 size_t basename_len; 926 php_u_basename(xce-> name.ustr.val, xce->name.ustr.len, NULL, 0, &basename.u, &basename_len TSRMLS_CC);961 php_u_basename(xce->entry.name.ustr.val, xce->entry.name.ustr.len, NULL, 0, &basename.u, &basename_len TSRMLS_CC); 927 962 return HASH_ZSTR_L(IS_UNICODE, basename, basename_len); 928 963 } … … 934 969 size_t basename_len; 935 970 #ifdef ZEND_ENGINE_2 936 php_basename(xce-> name.str.val, xce->name.str.len, "", 0, &basename, &basename_len TSRMLS_CC);971 php_basename(xce->entry.name.str.val, xce->entry.name.str.len, "", 0, &basename, &basename_len TSRMLS_CC); 937 972 #else 938 basename = php_basename(xce-> name.str.val, xce->name.str.len, "", 0);973 basename = php_basename(xce->entry.name.str.val, xce->entry.name.str.len, "", 0); 939 974 basename_len = strlen(basename); 940 975 #endif … … 945 980 } 946 981 /* }}} */ 947 static void xc_entry_free_key_php(xc_entry_t *xce TSRMLS_DC) /* {{{ */ 982 #define xc_entry_hash_var xc_entry_hash_name 983 static inline xc_hash_value_t xc_entry_hash_php(xc_entry_php_t *xce TSRMLS_DC) /* {{{ */ 984 { 985 return 986 #ifdef HAVE_INODE 987 xce->file_inode ? HASH(xce->file_device + xce->file_inode) : 988 #endif 989 xc_entry_hash_php_basename(xce TSRMLS_CC); 990 } 991 /* }}} */ 992 static void xc_entry_free_key_php(xc_entry_php_t *xce TSRMLS_DC) /* {{{ */ 948 993 { 949 994 #define X_FREE(var) do {\ … … 962 1007 /* }}} */ 963 1008 964 static int xc_entry_init_key_php(xc_entry_ t *xce, const char *filename TSRMLS_DC) /* {{{ */1009 static int xc_entry_init_key_php(xc_entry_php_t *xce, const char *filename TSRMLS_DC) /* {{{ */ 965 1010 { 966 1011 char opened_path_buffer[MAXPATHLEN]; … … 1027 1072 } 1028 1073 1029 xce-> mtime= pbuf->st_mtime;1074 xce->file_mtime = pbuf->st_mtime; 1030 1075 #ifdef HAVE_INODE 1031 xce-> device= pbuf->st_dev;1032 xce-> inode= pbuf->st_ino;1033 #endif 1034 xce-> data.php->sourcesize = pbuf->st_size;1076 xce->file_device = pbuf->st_dev; 1077 xce->file_inode = pbuf->st_ino; 1078 #endif 1079 xce->entry.data.php->file_size = pbuf->st_size; 1035 1080 } 1036 1081 else { /* XG(inode) */ 1037 xce-> mtime= 0;1082 xce->file_mtime = 0; 1038 1083 #ifdef HAVE_INODE 1039 xce-> device= 0;1040 xce-> inode= 0;1041 #endif 1042 xce-> data.php->sourcesize = 0;1084 xce->file_device = 0; 1085 xce->file_inode = 0; 1086 #endif 1087 xce->entry.data.php->file_size = 0; 1043 1088 } 1044 1089 1045 1090 #ifdef HAVE_INODE 1046 if (!xce-> inode)1091 if (!xce->file_inode) 1047 1092 #endif 1048 1093 { … … 1055 1100 } 1056 1101 1057 UNISW(NOTHING, xce-> name_type = IS_STRING;)1058 xce-> name.str.val = (char *) filename;1059 xce-> name.str.len = strlen(filename);1102 UNISW(NOTHING, xce->entry.name_type = IS_STRING;) 1103 xce->entry.name.str.val = (char *) filename; 1104 xce->entry.name.str.len = strlen(filename); 1060 1105 1061 1106 cacheid = xc_php_hcache.size > 1 ? xc_hash_fold(xc_entry_hash_php_basename(xce TSRMLS_CC), &xc_php_hcache) : 0; 1062 xce-> cache = xc_php_caches[cacheid];1063 xce-> hvalue = xc_hash_fold(xc_entry_hash_php(xce TSRMLS_CC), &xc_php_hentry);1064 xce-> type = XC_TYPE_PHP;1107 xce->entry.cache = xc_php_caches[cacheid]; 1108 xce->entry.hvalue = xc_hash_fold(xc_entry_hash_php(xce TSRMLS_CC), &xc_php_hentry); 1109 xce->entry.type = XC_TYPE_PHP; 1065 1110 xce->filepath = NULL; 1066 1111 xce->dirpath = NULL; … … 1078 1123 } 1079 1124 /* }}} */ 1080 static int xc_entry_init_key_php_md5(xc_entry_data_php_t *php, xc_entry_ t *xce TSRMLS_DC) /* {{{ */1125 static int xc_entry_init_key_php_md5(xc_entry_data_php_t *php, xc_entry_php_t *xce TSRMLS_DC) /* {{{ */ 1081 1126 { 1082 1127 unsigned char buf[1024]; … … 1086 1131 ulong old_rsid = EG(regular_list).nNextFreeElement; 1087 1132 1088 stream = php_stream_open_wrapper(xce-> name.str.val, "rb", USE_PATH | REPORT_ERRORS | ENFORCE_SAFE_MODE | STREAM_DISABLE_OPEN_BASEDIR, NULL);1133 stream = php_stream_open_wrapper(xce->entry.name.str.val, "rb", USE_PATH | REPORT_ERRORS | ENFORCE_SAFE_MODE | STREAM_DISABLE_OPEN_BASEDIR, NULL); 1089 1134 if (!stream) { 1090 1135 return FAILURE; … … 1106 1151 } 1107 1152 1108 php->cache = xce-> cache;1153 php->cache = xce->entry.cache; 1109 1154 php->hvalue = (xc_php_hash_md5(php TSRMLS_CC) & php->cache->hphp->mask); 1110 1155 #ifdef XCACHE_DEBUG … … 1119 1164 } 1120 1165 /* }}} */ 1121 static void xc_entry_init_key_php_entry(xc_entry_ t *xce, ZEND_24(const) char *filepath TSRMLS_DC) /* {{{*/1166 static void xc_entry_init_key_php_entry(xc_entry_php_t *xce, ZEND_24(const) char *filepath TSRMLS_DC) /* {{{*/ 1122 1167 { 1123 1168 xce->filepath = filepath; … … 1178 1223 } xc_const_usage_t; 1179 1224 /* }}} */ 1180 static void xc_collect_op_array_info(xc_entry_ t *xce, xc_entry_data_php_t *php, xc_const_usage_t *usage, xc_op_array_info_t *op_array_info, zend_op_array *op_array TSRMLS_DC) /* {{{ */1225 static void xc_collect_op_array_info(xc_entry_php_t *xce, xc_entry_data_php_t *php, xc_const_usage_t *usage, xc_op_array_info_t *op_array_info, zend_op_array *op_array TSRMLS_DC) /* {{{ */ 1181 1226 { 1182 1227 int i; … … 1277 1322 } 1278 1323 /* }}} */ 1279 void xc_fix_op_array_info(const xc_entry_ t *xce, const xc_entry_data_php_t *php, zend_op_array *op_array, int shallow_copy, const xc_op_array_info_t *op_array_info TSRMLS_DC) /* {{{ */1324 void xc_fix_op_array_info(const xc_entry_php_t *xce, const xc_entry_data_php_t *php, zend_op_array *op_array, int shallow_copy, const xc_op_array_info_t *op_array_info TSRMLS_DC) /* {{{ */ 1280 1325 { 1281 1326 int i; … … 1468 1513 } 1469 1514 /* }}} */ 1470 static zend_op_array *xc_compile_php(xc_entry_ t *xce, xc_entry_data_php_t *php, zend_file_handle *h, int type TSRMLS_DC) /* {{{ */1515 static zend_op_array *xc_compile_php(xc_entry_php_t *xce, xc_entry_data_php_t *php, zend_file_handle *h, int type TSRMLS_DC) /* {{{ */ 1471 1516 { 1472 1517 zend_op_array *op_array; … … 1701 1746 } 1702 1747 /* }}} */ 1703 static zend_op_array *xc_compile_restore(xc_entry_ t *stored_xce, zend_file_handle *h TSRMLS_DC) /* {{{ */1748 static zend_op_array *xc_compile_restore(xc_entry_php_t *stored_xce, zend_file_handle *h TSRMLS_DC) /* {{{ */ 1704 1749 { 1705 1750 zend_op_array *op_array; 1706 xc_entry_ t xce;1751 xc_entry_php_t xce; 1707 1752 xc_entry_data_php_t php; 1708 1753 zend_bool catched; 1709 1754 1710 1755 CG(in_compilation) = 1; 1711 CG(compiled_filename) = stored_xce-> name.str.val;1756 CG(compiled_filename) = stored_xce->entry.name.str.val; 1712 1757 CG(zend_lineno) = 0; 1713 TRACE("restoring %s", stored_xce-> name.str.val);1714 xc_processor_restore_xc_entry_ t(&xce, stored_xce TSRMLS_CC);1715 xc_processor_restore_xc_entry_data_php_t(stored_xce, &php, xce. data.php, xc_readonly_protection TSRMLS_CC);1716 xce. data.php = &php;1758 TRACE("restoring %s", stored_xce->entry.name.str.val); 1759 xc_processor_restore_xc_entry_php_t(&xce, stored_xce TSRMLS_CC); 1760 xc_processor_restore_xc_entry_data_php_t(stored_xce, &php, xce.entry.data.php, xc_readonly_protection TSRMLS_CC); 1761 xce.entry.data.php = &php; 1717 1762 #ifdef SHOW_DPRINT 1718 1763 xc_dprint(&xce, 0 TSRMLS_CC); … … 1753 1798 } 1754 1799 /* }}} */ 1755 static zend_op_array *xc_compile_file_ex(xc_entry_ t *xce, zend_file_handle *h, int type TSRMLS_DC) /* {{{ */1800 static zend_op_array *xc_compile_file_ex(xc_entry_php_t *xce, zend_file_handle *h, int type TSRMLS_DC) /* {{{ */ 1756 1801 { 1757 1802 zend_op_array *op_array; 1758 xc_entry_ t *stored_xce;1803 xc_entry_php_t *stored_xce; 1759 1804 xc_entry_data_php_t *stored_php; 1760 xc_cache_t *cache = xce-> cache;1805 xc_cache_t *cache = xce->entry.cache; 1761 1806 zend_bool gaveup = 0; 1762 1807 zend_bool catched = 0; … … 1773 1818 stored_php = NULL; 1774 1819 ENTER_LOCK_EX(cache) { 1775 stored_xce = xc_entry_find_dmz(xce TSRMLS_CC);1820 stored_xce = (xc_entry_php_t *) xc_entry_find_dmz((xc_entry_t *) xce TSRMLS_CC); 1776 1821 if (stored_xce) { 1777 1822 xc_cache_hit_dmz(cache TSRMLS_CC); … … 1784 1829 TRACE("miss %s", xce->name.str.val); 1785 1830 1786 if (xc_entry_init_key_php_md5(xce-> data.php, xce TSRMLS_CC) != SUCCESS) {1831 if (xc_entry_init_key_php_md5(xce->entry.data.php, xce TSRMLS_CC) != SUCCESS) { 1787 1832 gaveup = 1; 1788 1833 break; 1789 1834 } 1790 1835 1791 stored_php = xc_php_find_dmz(xce-> data.php TSRMLS_CC);1836 stored_php = xc_php_find_dmz(xce->entry.data.php TSRMLS_CC); 1792 1837 1793 1838 /* miss but compiling */ … … 1829 1874 newlycompiled = 0; 1830 1875 xc_entry_init_key_php_entry(xce, h->opened_path ? h->opened_path : h->filename TSRMLS_CC); 1831 xce-> data.php = stored_php;1876 xce->entry.data.php = stored_php; 1832 1877 } 1833 1878 else { … … 1838 1883 1839 1884 #ifdef HAVE_XCACHE_CONSTANT 1840 xce-> data.php->constinfos = NULL;1841 #endif 1842 xce-> data.php->funcinfos = NULL;1843 xce-> data.php->classinfos = NULL;1885 xce->entry.data.php->constinfos = NULL; 1886 #endif 1887 xce->entry.data.php->funcinfos = NULL; 1888 xce->entry.data.php->classinfos = NULL; 1844 1889 #ifdef ZEND_ENGINE_2_1 1845 xce-> data.php->autoglobals = NULL;1846 #endif 1847 1848 memset(&xce-> data.php->op_array_info, 0, sizeof(xce->data.php->op_array_info));1890 xce->entry.data.php->autoglobals = NULL; 1891 #endif 1892 1893 memset(&xce->entry.data.php->op_array_info, 0, sizeof(xce->entry.data.php->op_array_info)); 1849 1894 1850 1895 zend_try { 1851 op_array = xc_compile_php(xce, xce-> data.php, h, type TSRMLS_CC);1896 op_array = xc_compile_php(xce, xce->entry.data.php, h, type TSRMLS_CC); 1852 1897 } zend_catch { 1853 1898 catched = 1; … … 1859 1904 1860 1905 /* not cachable */ 1861 if (!xce-> data.php->op_array) {1906 if (!xce->entry.data.php->op_array) { 1862 1907 cache->compiling = 0; 1863 1908 /* it's not cachable, but don't scare the users with high misses */ … … 1874 1919 * WARNING: this code is required to be after compile 1875 1920 */ 1876 if (xce-> inode) {1921 if (xce->file_inode) { 1877 1922 const char *filename = h->opened_path ? h->opened_path : h->filename; 1878 if (xce-> name.str.val != filename) {1879 xce-> name.str.val = (char *) filename;1880 xce-> name.str.len = strlen(filename);1923 if (xce->entry.name.str.val != filename) { 1924 xce->entry.name.str.val = (char *) filename; 1925 xce->entry.name.str.len = strlen(filename); 1881 1926 } 1882 1927 } … … 1890 1935 /* php_store */ 1891 1936 if (newlycompiled) { 1892 stored_php = xc_php_store_dmz(xce-> data.php TSRMLS_CC);1937 stored_php = xc_php_store_dmz(xce->entry.data.php TSRMLS_CC); 1893 1938 if (!stored_php) { 1894 1939 /* error */ … … 1898 1943 /* entry_store */ 1899 1944 xc_php_addref_dmz(stored_php); 1900 stored_xce = xc_entry_ store_dmz(xce TSRMLS_CC);1945 stored_xce = xc_entry_php_store_dmz(xce TSRMLS_CC); 1901 1946 if (stored_xce) { 1902 stored_xce-> data.php = stored_php;1947 stored_xce->entry.data.php = stored_php; 1903 1948 } 1904 1949 else { … … 1916 1961 1917 1962 if (newlycompiled) { 1918 xc_free_php(xce-> data.php TSRMLS_CC);1963 xc_free_php(xce->entry.data.php TSRMLS_CC); 1919 1964 } 1920 1965 … … 1947 1992 err_aftersandbox: 1948 1993 if (newlycompiled) { 1949 xc_free_php(xce-> data.php TSRMLS_CC);1994 xc_free_php(xce->entry.data.php TSRMLS_CC); 1950 1995 xc_sandbox_free(&sandbox, XC_NoInstall TSRMLS_CC); 1951 1996 } … … 1962 2007 { 1963 2008 zend_op_array *op_array; 1964 xc_entry_ t xce;2009 xc_entry_php_t xce; 1965 2010 xc_entry_data_php_t php; 1966 2011 const char *filename; … … 1976 2021 /* {{{ entry_init_key */ 1977 2022 filename = h->opened_path ? h->opened_path : h->filename; 1978 xce. data.php = &php;2023 xce.entry.data.php = &php; 1979 2024 if (xc_entry_init_key_php(&xce, filename TSRMLS_CC) != SUCCESS) { 1980 2025 TRACE("failed to init key for %s", filename); … … 2656 2701 { 2657 2702 xc_entry_t xce, *stored_xce; 2658 xc_entry_data_var_t var;2659 2703 zval *name; 2660 2704 int found = 0; … … 2668 2712 return; 2669 2713 } 2670 xce.data.var = &var;2671 2714 xc_entry_init_key_var(&xce, name TSRMLS_CC); 2672 2715 … … 2676 2719 if (!VAR_ENTRY_EXPIRED(stored_xce)) { 2677 2720 found = 1; 2678 xc_processor_restore_zval(return_value, stored_xce->data.var ->value, stored_xce->data.var->have_references TSRMLS_CC);2721 xc_processor_restore_zval(return_value, stored_xce->data.var.value, stored_xce->data.var.have_references TSRMLS_CC); 2679 2722 /* return */ 2680 2723 break; … … 2700 2743 { 2701 2744 xc_entry_t xce, *stored_xce; 2702 xc_entry_data_var_t var;2703 2745 zval *name; 2704 2746 zval *value; … … 2719 2761 } 2720 2762 2721 xce.data.var = &var;2722 2763 xc_entry_init_key_var(&xce, name TSRMLS_CC); 2723 2764 … … 2727 2768 xc_entry_remove_dmz(stored_xce TSRMLS_CC); 2728 2769 } 2729 var.value = value;2770 xce.data.var.value = value; 2730 2771 RETVAL_BOOL(xc_entry_store_dmz(&xce TSRMLS_CC) != NULL ? 1 : 0); 2731 2772 } LEAVE_LOCK(xce.cache); … … 2737 2778 { 2738 2779 xc_entry_t xce, *stored_xce; 2739 xc_entry_data_var_t var;2740 2780 zval *name; 2741 2781 int found = 0; … … 2749 2789 return; 2750 2790 } 2751 xce.data.var = &var;2752 2791 xc_entry_init_key_var(&xce, name TSRMLS_CC); 2753 2792 … … 2781 2820 { 2782 2821 xc_entry_t xce, *stored_xce; 2783 xc_entry_data_var_t var;2784 2822 zval *name; 2785 2823 … … 2792 2830 return; 2793 2831 } 2794 xce.data.var = &var;2795 2832 xc_entry_init_key_var(&xce, name TSRMLS_CC); 2796 2833 … … 2843 2880 { 2844 2881 xc_entry_t xce, *stored_xce; 2845 xc_entry_data_var_t var, *stored_var;2846 2882 zval *name; 2847 2883 long count = 1; … … 2864 2900 } 2865 2901 2866 xce.data.var = &var;2867 2902 xc_entry_init_key_var(&xce, name TSRMLS_CC); 2868 2903 … … 2879 2914 else { 2880 2915 /* do it in place */ 2881 stored_var =stored_xce->data.var;2916 xc_entry_data_var_t *stored_var = &stored_xce->data.var; 2882 2917 if (Z_TYPE_P(stored_var->value) == IS_LONG) { 2883 2918 zval *zv; … … 2895 2930 else { 2896 2931 TRACE("%s", "incdec: notlong"); 2897 xc_processor_restore_zval(&oldzval, stored_xce->data.var ->value, stored_xce->data.var->have_references TSRMLS_CC);2932 xc_processor_restore_zval(&oldzval, stored_xce->data.var.value, stored_xce->data.var.have_references TSRMLS_CC); 2898 2933 convert_to_long(&oldzval); 2899 2934 value = Z_LVAL(oldzval); … … 2908 2943 value += (inc == 1 ? count : - count); 2909 2944 RETVAL_LONG(value); 2910 var.value = return_value;2945 stored_xce->data.var.value = return_value; 2911 2946 2912 2947 if (stored_xce) { -
trunk/xcache.h
r846 r851 262 262 zend_ulong errors; 263 263 xc_lock_t *lck; 264 xc_shm_t *shm; /* towhich shm contains us */265 xc_mem_t *mem; /* towhich mem contains us */264 xc_shm_t *shm; /* which shm contains us */ 265 xc_mem_t *mem; /* which mem contains us */ 266 266 267 267 xc_entry_t **entries; … … 369 369 /* {{{ xc_entry_data_php_t */ 370 370 struct _xc_entry_data_php_t { 371 xc_hash_value_t hvalue; /* hash of md5 */371 xc_hash_value_t hvalue; 372 372 xc_entry_data_php_t *next; 373 xc_cache_t *cache; /* which cache it's on */373 xc_cache_t *cache; 374 374 375 375 xc_md5sum_t md5; /* md5sum of the source */ 376 376 zend_ulong refcount; /* count of entries referencing to this data */ 377 377 378 size_t sourcesize;378 size_t file_size; 379 379 zend_ulong hits; /* hits of this php */ 380 380 size_t size; … … 420 420 /* {{{ xc_entry_t */ 421 421 struct _xc_entry_t { 422 xc_hash_value_t hvalue; 423 xc_entry_t *next; 424 xc_cache_t *cache; 425 422 426 xc_entry_type_t type; 423 xc_hash_value_t hvalue; 424 xc_entry_t *next; 425 xc_cache_t *cache; /* which cache it's on */ 426 427 size_t size; 428 zend_ulong refcount; /* count of instances holding this entry */ 427 size_t size; 428 429 time_t ctime; /* creation ctime of this entry */ 430 time_t atime; /* access atime of this entry */ 431 time_t dtime; /* deletion time of this entry */ 429 432 zend_ulong hits; 430 time_t ctime; /* the ctime of this entry */ 431 time_t atime; /* the atime of this entry */ 432 time_t dtime; /* the deletion time of this entry */ 433 long ttl; /* ttl of time entry, var only */ 433 long ttl; 434 434 435 435 #ifdef IS_UNICODE … … 440 440 union { 441 441 xc_entry_data_php_t *php; 442 xc_entry_data_var_t *var;442 xc_entry_data_var_t var; 443 443 } data; 444 445 time_t mtime; /* the mtime of origin source file */ 444 }; 445 446 typedef struct { 447 xc_entry_t entry; 448 449 zend_ulong refcount; /* count of php instances holding this entry */ 450 time_t file_mtime; 446 451 #ifdef HAVE_INODE 447 int device; /* the filesystem device */ 448 int inode; /* the filesystem inode */ 449 #endif 450 451 /* php only */ 452 int file_device; 453 int file_inode; 454 #endif 455 452 456 int filepath_len; 453 457 ZEND_24(const) char *filepath; … … 455 459 char *dirpath; 456 460 #ifdef IS_UNICODE 461 int ufilepath_len; 457 462 UChar *ufilepath; 458 int u filepath_len;463 int udirpath_len; 459 464 UChar *udirpath; 460 int udirpath_len; 461 #endif 462 463 }; 465 #endif 466 } xc_entry_php_t; 464 467 /* }}} */ 465 468 … … 480 483 /* }}} */ 481 484 void xc_gc_add_op_array(xc_gc_op_array_t *gc_op_array TSRMLS_DC); 482 void xc_fix_op_array_info(const xc_entry_ t *xce, const xc_entry_data_php_t *php, zend_op_array *op_array, int shallow_copy, const xc_op_array_info_t *op_array_info TSRMLS_DC);485 void xc_fix_op_array_info(const xc_entry_php_t *xce, const xc_entry_data_php_t *php, zend_op_array *op_array, int shallow_copy, const xc_op_array_info_t *op_array_info TSRMLS_DC); 483 486 484 487 #endif /* __XCACHE_H */
Note: See TracChangeset
for help on using the changeset viewer.

