Changeset 870
Legend:
- Unmodified
- Added
- Removed
-
trunk/xcache-test.ini
r829 r870 8 8 zend_extension=./modules/xcache.so 9 9 xcache.cacher = On 10 xcache.test=1 10 xcache.test = 1 11 xcache.stat = 1 11 12 xcache.experimental = On 12 13 xcache.size = 16M -
trunk/xcache.c
r869 r870 897 897 898 898 #undef X_FREE 899 } 900 /* }}} */ 901 static char *xc_expand_url(const char *filepath, char *real_path TSRMLS_DC) /* {{{ */ 902 { 903 if (strstr(filepath, "://") != NULL) { 904 size_t filepath_len = strlen(filepath); 905 size_t copy_len = filepath_len > MAXPATHLEN - 1 ? MAXPATHLEN - 1 : filepath_len; 906 memcpy(real_path, filepath, filepath_len); 907 real_path[copy_len] = '\0'; 908 return real_path; 909 } 910 return expand_filepath(filepath, real_path TSRMLS_CC); 899 911 } 900 912 /* }}} */ … … 980 992 xc_compiler_t *compiler = entry_find_include_path_data->compiler; 981 993 982 compiler->new_entry.entry.name.str.val = expand_filepath(filepath, compiler->opened_path_buffer TSRMLS_CC);994 compiler->new_entry.entry.name.str.val = xc_expand_url(filepath, compiler->opened_path_buffer TSRMLS_CC); 983 995 compiler->new_entry.entry.name.str.len = strlen(compiler->new_entry.entry.name.str.val); 984 996 … … 1018 1030 } 1019 1031 1020 compiler->opened_path = expand_filepath(SG(request_info).path_translated, compiler->opened_path_buffer TSRMLS_CC);1032 compiler->opened_path = xc_expand_url(SG(request_info).path_translated, compiler->opened_path_buffer TSRMLS_CC); 1021 1033 return SUCCESS; 1022 1034 } … … 1027 1039 return FAILURE; 1028 1040 } 1029 compiler->opened_path = expand_filepath(compiler->filename, compiler->opened_path_buffer TSRMLS_CC);1041 compiler->opened_path = xc_expand_url(compiler->filename, compiler->opened_path_buffer TSRMLS_CC); 1030 1042 return SUCCESS; 1031 1043 } … … 1045 1057 } 1046 1058 1047 compiler->opened_path = expand_filepath(compiler->filename, compiler->opened_path_buffer TSRMLS_CC);1059 compiler->opened_path = xc_expand_url(compiler->filename, compiler->opened_path_buffer TSRMLS_CC); 1048 1060 return SUCCESS; 1049 1061 } 1050 1062 1063 return FAILURE; 1064 } 1065 /* }}} */ 1066 static int xc_entry_php_resolve_opened_path(xc_compiler_t *compiler, struct stat *statbuf TSRMLS_DC) /* {{{ */ 1067 { 1068 if (xc_entry_php_quick_resolve_opened_path(compiler, statbuf TSRMLS_CC) == SUCCESS) { 1069 /* opened_path resolved */ 1070 return SUCCESS; 1071 } 1072 /* fall back to real stat call */ 1073 else { 1074 #ifdef ZEND_ENGINE_2_3 1075 char *opened_path = php_resolve_path(compiler->filename, compiler->filename_len, PG(include_path)); 1076 if (opened_path) { 1077 strcpy(compiler->opened_path_buffer, opened_path); 1078 efree(opened_path); 1079 compiler->opened_path = compiler->opened_path_buffer; 1080 if (!statbuf || VCWD_STAT(compiler->filename, statbuf) == 0) { 1081 return SUCCESS; 1082 } 1083 } 1084 #else 1085 char path_buffer[MAXPATHLEN]; 1086 if (xc_include_path_stat(compiler->filename, path_buffer, statbuf TSRMLS_CC) == SUCCESS) { 1087 compiler->opened_path = xc_expand_url(path_buffer, compiler->opened_path_buffer TSRMLS_CC); 1088 return SUCCESS; 1089 } 1090 #endif 1091 } 1051 1092 return FAILURE; 1052 1093 } … … 1058 1099 time_t delta; 1059 1100 1060 if (xc_entry_php_quick_resolve_opened_path(compiler, &buf TSRMLS_CC) != SUCCESS) { 1061 char path_buffer[MAXPATHLEN]; 1062 if (xc_include_path_stat(compiler->filename, path_buffer, &buf TSRMLS_CC) != SUCCESS) { 1101 if (compiler->opened_path) { 1102 if (VCWD_STAT(compiler->opened_path, &buf) != 0) { 1063 1103 return FAILURE; 1064 1104 } 1065 compiler->opened_path = expand_filepath(path_buffer, compiler->opened_path_buffer TSRMLS_CC); 1105 } 1106 else { 1107 if (xc_entry_php_resolve_opened_path(compiler, &buf TSRMLS_CC) != SUCCESS) { 1108 return FAILURE; 1109 } 1066 1110 } 1067 1111 … … 1098 1142 ) 1099 1143 { 1100 const char *filename_end = compiler->filename + strlen(compiler->filename);1144 const char *filename_end = compiler->filename + compiler->filename_len; 1101 1145 const char *basename = filename_end - 1; 1102 1146 … … 1858 1902 ENTER_LOCK_EX(cache) { 1859 1903 if (!compiler->opened_path && xc_entry_find_include_path_dmz(compiler, compiler->filename, &stored_entry TSRMLS_CC) == SUCCESS) { 1860 compiler->opened_path = compiler-> opened_path_buffer;1904 compiler->opened_path = compiler->new_entry.entry.name.str.val; 1861 1905 } 1862 1906 else { 1863 if (!compiler->opened_path) { 1864 if (xc_entry_php_quick_resolve_opened_path(compiler, NULL TSRMLS_CC) == SUCCESS) { 1865 /* opened_path resolved */ 1866 } 1867 /* fall back to real stat call */ 1868 else { 1869 char path_buffer[MAXPATHLEN]; 1870 if (xc_include_path_stat(compiler->filename, path_buffer, &statbuf TSRMLS_CC) == SUCCESS) { 1871 compiler->opened_path = expand_filepath(path_buffer, compiler->opened_path_buffer TSRMLS_CC); 1872 } 1873 else { 1874 gaveup = 1; 1875 break; 1876 } 1877 } 1907 if (!compiler->opened_path && xc_entry_php_resolve_opened_path(compiler, NULL TSRMLS_CC) != SUCCESS) { 1908 gaveup = 1; 1909 break; 1878 1910 } 1879 1911 … … 2050 2082 || !h->filename 2051 2083 || !SG(request_info).path_translated 2052 || strstr(h->filename, "://") != NULL) { 2084 || strstr(h->filename, "://") != NULL 2085 #ifdef ZEND_ENGINE_2_3 2086 /* supported by php_resolve_path */ 2087 || !XG(stat) && strstr(PG(include_path), "://") != NULL 2088 #else 2089 || strstr(PG(include_path), "://") != NULL 2090 #endif 2091 ) { 2053 2092 op_array = old_compile_file(h, type TSRMLS_CC); 2054 2093 TRACE("%s", "cacher not enabled"); … … 2059 2098 compiler.opened_path = h->opened_path; 2060 2099 compiler.filename = compiler.opened_path ? compiler.opened_path : h->filename; 2100 compiler.filename_len = strlen(compiler.filename); 2061 2101 if (xc_entry_php_init_key(&compiler TSRMLS_CC) != SUCCESS) { 2062 2102 TRACE("failed to init key for %s", compiler.filename); -
trunk/xcache.h
r866 r870 465 465 typedef struct xc_compiler_t { /* {{{ */ 466 466 const char *filename; 467 size_t filename_len; 467 468 const char *opened_path; 468 469 char opened_path_buffer[MAXPATHLEN];

