Changeset 165
- Timestamp:
- 2006-09-13T14:22:57+02:00 (7 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
xcache.c (modified) (14 diffs)
-
xcache.h (modified) (1 diff)
-
xcache.ini (modified) (1 diff)
-
xcache_globals.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/xcache.c
r164 r165 121 121 xc_entry_data_php_t *ap = a->data.php; 122 122 xc_entry_data_php_t *bp = b->data.php; 123 return ap->inode == bp->inode 124 && ap->device == bp->device; 123 if (ap->inode) { 124 return ap->inode == bp->inode 125 && ap->device == bp->device; 126 } 125 127 } while(0); 126 128 #endif … … 618 620 static int xc_stat(const char *filename, const char *include_path, struct stat *pbuf TSRMLS_DC) /* {{{ */ 619 621 { 620 char filepath[ 1024];622 char filepath[MAXPATHLEN]; 621 623 char *paths, *path; 622 624 char *tokbuf; … … 628 630 629 631 for (path = php_strtok_r(paths, tokens, &tokbuf); path; path = php_strtok_r(NULL, tokens, &tokbuf)) { 630 if (s trlen(path) + strlen(filename) + 1 > 1024) {632 if (snprintf(filepath, sizeof(filepath), "%s/%s", path, filename) >= MAXPATHLEN - 1) { 631 633 continue; 632 634 } 633 snprintf(filepath, sizeof(filepath), "%s/%s", path, filename);634 635 if (VCWD_STAT(filepath, pbuf) == 0) { 635 636 free_alloca(paths); … … 649 650 #define HASH_STR(s) HASH_STR_L(s, strlen(s) + 1) 650 651 #define HASH_NUM(n) HASH(n) 651 static inline xc_hash_value_t xc_entry_hash_ var(xc_entry_t *xce TSRMLS_DC) /* {{{ */652 static inline xc_hash_value_t xc_entry_hash_name(xc_entry_t *xce TSRMLS_DC) /* {{{ */ 652 653 { 653 654 return UNISW(NOTHING, UG(unicode) ? HASH_USTR_L(xce->name_type, xce->name.uni.val, xce->name.uni.len) :) … … 655 656 } 656 657 /* }}} */ 658 #define xc_entry_hash_var xc_entry_hash_name 657 659 static inline xc_hash_value_t xc_entry_hash_php(xc_entry_t *xce TSRMLS_DC) /* {{{ */ 658 660 { 659 661 #ifdef HAVE_INODE 660 return HASH(xce->data.php->device + xce->data.php->inode); 661 #else 662 return xc_entry_hash_var(xce TSRMLS_CC); 663 #endif 664 } 665 /* }}} */ 666 static int xc_entry_init_key_php(xc_entry_t *xce, char *filename TSRMLS_DC) /* {{{ */ 662 if (xce->data.php->inode) { 663 return HASH(xce->data.php->device + xce->data.php->inode); 664 } 665 #endif 666 return xc_entry_hash_name(xce TSRMLS_CC); 667 } 668 /* }}} */ 669 static int xc_entry_init_key_php(xc_entry_t *xce, char *filename, char *opened_path_buffer TSRMLS_DC) /* {{{ */ 667 670 { 668 671 struct stat buf, *pbuf; … … 676 679 } 677 680 678 do { 681 php = xce->data.php; 682 683 if (XG(stat)) { 679 684 if (strcmp(SG(request_info).path_translated, filename) == 0) { 680 685 /* sapi has already done this stat() for us */ 681 686 pbuf = sapi_get_stat(TSRMLS_C); 682 687 if (pbuf) { 683 break;688 goto stat_done; 684 689 } 685 690 } … … 691 696 return 0; 692 697 } 693 break;698 goto stat_done; 694 699 } 695 700 … … 707 712 return 0; 708 713 } 709 break;714 goto stat_done; 710 715 } 711 716 not_relative_path: … … 715 720 return 0; 716 721 } 717 } while (0); 718 719 if (XG(request_time) - pbuf->st_mtime < 2) { 720 return 0; 722 723 /* fall */ 724 725 stat_done: 726 if (XG(request_time) - pbuf->st_mtime < 2) { 727 return 0; 728 } 729 730 php->mtime = pbuf->st_mtime; 731 #ifdef HAVE_INODE 732 php->device = pbuf->st_dev; 733 php->inode = pbuf->st_ino; 734 #endif 735 php->sourcesize = pbuf->st_size; 736 } 737 else { /* XG(inode) */ 738 php->mtime = 0; 739 #ifdef HAVE_INODE 740 php->device = 0; 741 php->inode = 0; 742 #endif 743 php->sourcesize = 0; 744 } 745 746 #ifdef HAVE_INODE 747 if (!php->inode) 748 #endif 749 { 750 /* hash on filename, let's expand it to real path */ 751 filename = expand_filepath(filename, opened_path_buffer TSRMLS_CC); 752 if (filename == NULL) { 753 return 0; 754 } 721 755 } 722 756 … … 724 758 xce->name.str.val = filename; 725 759 xce->name.str.len = strlen(filename); 726 727 php = xce->data.php;728 php->mtime = pbuf->st_mtime;729 #ifdef HAVE_INODE730 php->device = pbuf->st_dev;731 php->inode = pbuf->st_ino;732 #endif733 php->sourcesize = pbuf->st_size;734 735 760 736 761 hv = xc_entry_hash_php(xce TSRMLS_CC); … … 754 779 zend_bool catched = 0; 755 780 char *filename; 781 char opened_path_buffer[MAXPATHLEN]; 756 782 int old_constinfo_cnt, old_funcinfo_cnt, old_classinfo_cnt; 757 783 … … 779 805 filename = h->opened_path ? h->opened_path : h->filename; 780 806 xce.data.php = &php; 781 if (!xc_entry_init_key_php(&xce, filename TSRMLS_CC)) {807 if (!xc_entry_init_key_php(&xce, filename, opened_path_buffer TSRMLS_CC)) { 782 808 return origin_compile_file(h, type TSRMLS_CC); 783 809 } … … 860 886 861 887 filename = h->opened_path ? h->opened_path : h->filename; 862 if (xce.name.str.val != filename) { 863 xce.name.str.val = filename; 864 xce.name.str.len = strlen(filename); 888 /* none-inode enabled entry hash/compare on name 889 * do not update to its name to real pathname 890 */ 891 #ifdef HAVE_INODE 892 if (xce.data.php->inode) 893 #endif 894 { 895 if (xce.name.str.val != filename) { 896 xce.name.str.val = filename; 897 xce.name.str.len = strlen(filename); 898 } 865 899 } 866 900 … … 2116 2150 2117 2151 STD_PHP_INI_BOOLEAN("xcache.cacher", "1", PHP_INI_ALL, OnUpdateBool, cacher, zend_xcache_globals, xcache_globals) 2152 STD_PHP_INI_BOOLEAN("xcache.stat", "1", PHP_INI_ALL, OnUpdateBool, stat, zend_xcache_globals, xcache_globals) 2118 2153 #ifdef HAVE_XCACHE_OPTIMIZER 2119 2154 STD_PHP_INI_BOOLEAN("xcache.optimizer", "0", PHP_INI_ALL, OnUpdateBool, optimizer, zend_xcache_globals, xcache_globals) -
trunk/xcache.h
r157 r165 19 19 #include "lock.h" 20 20 21 #ifndef ZEND_WIN32 22 /* UnDefine if your filesystem doesn't support inodes */ 23 # define HAVE_INODE 24 #endif 21 #define HAVE_INODE 25 22 #if !defined(ZEND_ENGINE_2_1) && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1 || PHP_MAJOR_VERSION > 5) 26 23 # define ZEND_ENGINE_2_1 -
trunk/xcache.ini
r162 r165 59 59 ; per request settings 60 60 xcache.cacher = On 61 xcache.stat = On 61 62 xcache.optimizer = Off 62 63 -
trunk/xcache_globals.h
r117 r165 2 2 ZEND_BEGIN_MODULE_GLOBALS(xcache) 3 3 zend_bool cacher; /* true if enabled */ 4 zend_bool stat; 4 5 #ifdef HAVE_XCACHE_OPTIMIZER 5 6 zend_bool optimizer; /* true if enabled */
Note: See TracChangeset
for help on using the changeset viewer.

