Changeset 846 for trunk/xcache.c
- Timestamp:
- 2012-03-26T11:41:19+02:00 (14 months ago)
- File:
-
- 1 edited
-
trunk/xcache.c (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/xcache.c
r840 r846 38 38 #include "utils.h" 39 39 40 #define VAR_ENTRY_EXPIRED(pentry) ((pentry)->ttl && XG(request_time) > pentry->ctime + (pentry)->ttl)40 #define VAR_ENTRY_EXPIRED(pentry) ((pentry)->ttl && XG(request_time) > (pentry)->ctime + (pentry)->ttl) 41 41 #define CHECK(x, e) do { if ((x) == NULL) { zend_error(E_ERROR, "XCache: " e); goto err; } } while (0) 42 #define LOCK(x) xc_lock( x->lck)43 #define UNLOCK(x) xc_unlock( x->lck)42 #define LOCK(x) xc_lock((x)->lck) 43 #define UNLOCK(x) xc_unlock((x)->lck) 44 44 45 45 #define ENTER_LOCK_EX(x) \ 46 xc_lock( x->lck); \46 xc_lock((x)->lck); \ 47 47 zend_try { \ 48 48 do … … 52 52 catched = 1; \ 53 53 } zend_end_try(); \ 54 xc_unlock( x->lck)54 xc_unlock((x)->lck) 55 55 56 56 #define ENTER_LOCK(x) do { \ … … 859 859 /* fall back to current directory */ 860 860 if (zend_is_executing(TSRMLS_C)) { 861 c har *path= zend_get_executed_filename(TSRMLS_C);862 if ( path && path[0] != '[') {863 int len = strlen( path);864 while ((--len >= 0) && !IS_SLASH( path[len])) {861 const char *executed_filename = zend_get_executed_filename(TSRMLS_C); 862 if (executed_filename && executed_filename[0] != '[') { 863 int len = strlen(executed_filename); 864 while ((--len >= 0) && !IS_SLASH(executed_filename[len])) { 865 865 /* skipped */ 866 866 } 867 867 if (len > 0 && len + strlen(filename) + 1 < MAXPATHLEN - 1) { 868 strcpy(filepath, path);868 strcpy(filepath, executed_filename); 869 869 strcpy(filepath + len + 1, filename); 870 870 if (VCWD_STAT(filepath, pbuf) == 0) { … … 886 886 887 887 #define HASH(i) (i) 888 #define HASH_ZSTR_L(t, s, l) HASH(zend_u_inline_hash_func( t, s, (l+ 1) * sizeof(UChar)))889 #define HASH_STR_S(s, l) HASH(zend_inline_hash_func( s, l))890 #define HASH_STR_L(s, l) HASH_STR_S( s, l+ 1)891 #define HASH_STR(s) HASH_STR_L( s, strlen(s) + 1)888 #define HASH_ZSTR_L(t, s, l) HASH(zend_u_inline_hash_func((t), (s), ((l) + 1) * sizeof(UChar))) 889 #define HASH_STR_S(s, l) HASH(zend_inline_hash_func((s), (l))) 890 #define HASH_STR_L(s, l) HASH_STR_S((s), (l) + 1) 891 #define HASH_STR(s) HASH_STR_L((s), strlen((s)) + 1) 892 892 #define HASH_NUM(n) HASH(n) 893 893 static inline xc_hash_value_t xc_hash_fold(xc_hash_value_t hvalue, const xc_hash_t *hasher) /* {{{ fold hash bits as needed */ … … 962 962 /* }}} */ 963 963 964 static int xc_entry_init_key_php(xc_entry_t *xce, c har *filename TSRMLS_DC) /* {{{ */964 static int xc_entry_init_key_php(xc_entry_t *xce, const char *filename TSRMLS_DC) /* {{{ */ 965 965 { 966 966 char opened_path_buffer[MAXPATHLEN]; 967 struct stat buf, *pbuf;968 xc_hash_value_t hv;969 967 int cacheid; 970 xc_entry_data_php_t *php;971 char *ptr;972 time_t delta;973 968 974 969 if (!filename || !SG(request_info).path_translated) { … … 980 975 } 981 976 982 php = xce->data.php;983 984 977 if (XG(stat)) { 978 struct stat buf, *pbuf; 979 985 980 if (strcmp(SG(request_info).path_translated, filename) == 0) { 986 981 /* sapi has already done this stat() for us */ … … 1002 997 /* relative path */ 1003 998 if (*filename == '.' && (IS_SLASH(filename[1]) || filename[1] == '.')) { 1004 ptr = filename + 1;999 const char *ptr = filename + 1; 1005 1000 if (*ptr == '.') { 1006 1001 while (*(++ptr) == '.'); … … 1025 1020 1026 1021 stat_done: 1027 delta = XG(request_time) - pbuf->st_mtime; 1028 if (abs(delta) < 2 && !xc_test) { 1029 return FAILURE; 1022 { 1023 time_t delta = XG(request_time) - pbuf->st_mtime; 1024 if (abs(delta) < 2 && !xc_test) { 1025 return FAILURE; 1026 } 1030 1027 } 1031 1028 … … 1035 1032 xce->inode = pbuf->st_ino; 1036 1033 #endif 1037 php->sourcesize= pbuf->st_size;1034 xce->data.php->sourcesize = pbuf->st_size; 1038 1035 } 1039 1036 else { /* XG(inode) */ … … 1043 1040 xce->inode = 0; 1044 1041 #endif 1045 php->sourcesize= 0;1042 xce->data.php->sourcesize = 0; 1046 1043 } 1047 1044 … … 1059 1056 1060 1057 UNISW(NOTHING, xce->name_type = IS_STRING;) 1061 xce->name.str.val = filename;1058 xce->name.str.val = (char *) filename; 1062 1059 xce->name.str.len = strlen(filename); 1063 1060 1064 if (xc_php_hcache.size > 1) { 1065 hv = xc_entry_hash_php_basename(xce TSRMLS_CC); 1066 cacheid = xc_hash_fold(hv, &xc_php_hcache); 1067 } 1068 else { 1069 cacheid = 0; 1070 } 1061 cacheid = xc_php_hcache.size > 1 ? xc_hash_fold(xc_entry_hash_php_basename(xce TSRMLS_CC), &xc_php_hcache) : 0; 1071 1062 xce->cache = xc_php_caches[cacheid]; 1072 1073 hv = xc_entry_hash_php(xce TSRMLS_CC); 1074 xce->hvalue = xc_hash_fold(hv, &xc_php_hentry); 1075 1063 xce->hvalue = xc_hash_fold(xc_entry_hash_php(xce TSRMLS_CC), &xc_php_hentry); 1076 1064 xce->type = XC_TYPE_PHP; 1077 1078 1065 xce->filepath = NULL; 1079 1066 xce->dirpath = NULL; … … 1088 1075 static inline xc_hash_value_t xc_php_hash_md5(xc_entry_data_php_t *php TSRMLS_DC) /* {{{ */ 1089 1076 { 1090 return HASH_STR_S( &php->md5, sizeof(php->md5));1077 return HASH_STR_S(php->md5.digest, sizeof(php->md5)); 1091 1078 } 1092 1079 /* }}} */ … … 1097 1084 int n; 1098 1085 php_stream *stream; 1099 xc_hash_value_t hv;1100 1086 ulong old_rsid = EG(regular_list).nNextFreeElement; 1101 1087 … … 1120 1106 } 1121 1107 1122 hv = xc_php_hash_md5(php TSRMLS_CC);1123 1108 php->cache = xce->cache; 1124 php->hvalue = ( hv& php->cache->hphp->mask);1109 php->hvalue = (xc_php_hash_md5(php TSRMLS_CC) & php->cache->hphp->mask); 1125 1110 #ifdef XCACHE_DEBUG 1126 1111 { … … 1134 1119 } 1135 1120 /* }}} */ 1136 static void xc_entry_init_key_php_entry(xc_entry_t *xce, char *filepath TSRMLS_DC) /* {{{*/1121 static void xc_entry_init_key_php_entry(xc_entry_t *xce, ZEND_24(const) char *filepath TSRMLS_DC) /* {{{*/ 1137 1122 { 1138 1123 xce->filepath = filepath; … … 1518 1503 /* }}} */ 1519 1504 /* {{{ prepare */ 1520 zend_restore_compiled_filename(h->opened_path ? h->opened_path : h->filename TSRMLS_CC);1505 zend_restore_compiled_filename(h->opened_path ? h->opened_path : (char *) h->filename TSRMLS_CC); 1521 1506 php->op_array = op_array; 1522 1507 … … 1890 1875 */ 1891 1876 if (xce->inode) { 1892 c har *filename = h->opened_path ? h->opened_path : h->filename;1877 const char *filename = h->opened_path ? h->opened_path : h->filename; 1893 1878 if (xce->name.str.val != filename) { 1894 xce->name.str.val = filename;1879 xce->name.str.val = (char *) filename; 1895 1880 xce->name.str.len = strlen(filename); 1896 1881 } … … 1979 1964 xc_entry_t xce; 1980 1965 xc_entry_data_php_t php; 1981 c har *filename;1966 const char *filename; 1982 1967 1983 1968 assert(xc_initized);
Note: See TracChangeset
for help on using the changeset viewer.

