Changeset 867 for trunk/xcache.c
- Timestamp:
- 03/29/2012 05:41:11 PM (14 months ago)
- Files:
-
- 1 modified
-
trunk/xcache.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/xcache.c
r866 r867 901 901 902 902 #define XC_INCLUDE_PATH_XSTAT_FUNC(name) zend_bool name(const char *absolute_path, size_t absolute_path_len, void *data TSRMLS_DC) 903 typedef XC_INCLUDE_PATH_XSTAT_FUNC((*include_path_xstat_fun _t));904 static zend_bool include_path_xstat(const char *filepath, char *opened_path_buffer, include_path_xstat_fun_t xstat_func, void *data TSRMLS_DC) /* {{{ */903 typedef XC_INCLUDE_PATH_XSTAT_FUNC((*include_path_xstat_func_t)); 904 static zend_bool xc_include_path_apply(const char *filepath, char *opened_path_buffer, include_path_xstat_func_t xstat_func, void *data TSRMLS_DC) /* {{{ */ 905 905 { 906 906 char *paths, *path; … … 963 963 } 964 964 /* }}} */ 965 static int xc_ stat(const char *filepath, char *opened_path_buffer, struct stat *pbuf TSRMLS_DC) /* {{{ */966 { 967 return include_path_xstat(filepath, opened_path_buffer, xc_stat_file, (void *) pbuf TSRMLS_DC)965 static int xc_include_path_stat(const char *filepath, char *opened_path_buffer, struct stat *pbuf TSRMLS_DC) /* {{{ */ 966 { 967 return xc_include_path_apply(filepath, opened_path_buffer, xc_stat_file, (void *) pbuf TSRMLS_DC) 968 968 ? SUCCESS 969 969 : FAILURE; 970 970 } 971 971 /* }}} */ 972 static int xc_entry_php_resolve_opened_path(xc_compiler_t *compiler TSRMLS_DC) /* {{{ */ 973 { 974 assert(!compiler->opened_path); 975 compiler->opened_path = expand_filepath(compiler->filename, compiler->opened_path_buffer TSRMLS_CC); 976 return SUCCESS; 972 typedef struct xc_entry_find_include_path_data_t { /* {{{ */ 973 xc_compiler_t *compiler; 974 xc_entry_php_t **stored_entry; 975 } xc_entry_find_include_path_data_t; 976 /* }}} */ 977 static XC_INCLUDE_PATH_XSTAT_FUNC(xc_entry_find_include_path_func_dmz) /* {{{ */ 978 { 979 xc_entry_find_include_path_data_t *entry_find_include_path_data = (xc_entry_find_include_path_data_t *) data; 980 xc_compiler_t *compiler = entry_find_include_path_data->compiler; 981 982 compiler->new_entry.entry.name.str.val = absolute_path; 983 compiler->new_entry.entry.name.str.len = strlen(compiler->new_entry.entry.name.str.val); 984 985 *entry_find_include_path_data->stored_entry = (xc_entry_php_t *) xc_entry_find_dmz( 986 XC_TYPE_PHP 987 , xc_php_caches[compiler->entry_hash.cacheid] 988 , compiler->entry_hash.entryslotid 989 , (xc_entry_t *) &compiler->new_entry 990 TSRMLS_CC); 991 992 return *entry_find_include_path_data->stored_entry ? 1 : 0; 993 } 994 /* }}} */ 995 static int xc_entry_find_include_path_dmz(xc_compiler_t *compiler, const char *filepath, char *opened_path_buffer, xc_entry_php_t **stored_entry TSRMLS_DC) /* {{{ */ 996 { 997 xc_entry_find_include_path_data_t entry_find_include_path_data; 998 entry_find_include_path_data.compiler = compiler; 999 entry_find_include_path_data.stored_entry = stored_entry; 1000 1001 return xc_include_path_apply(filepath, opened_path_buffer, xc_entry_find_include_path_func_dmz, (void *) &entry_find_include_path_data TSRMLS_DC) 1002 ? SUCCESS 1003 : FAILURE; 977 1004 } 978 1005 /* }}} */ … … 1031 1058 1032 1059 if (xc_entry_php_quick_resolve_opened_path(compiler, &buf TSRMLS_CC) != SUCCESS) { 1033 if (xc_ stat(compiler->filename, compiler->opened_path_buffer, &buf TSRMLS_CC) != SUCCESS) {1060 if (xc_include_path_stat(compiler->filename, compiler->opened_path_buffer, &buf TSRMLS_CC) != SUCCESS) { 1034 1061 return FAILURE; 1035 1062 } … … 1049 1076 #endif 1050 1077 } 1051 else { /* XG(inode) */ 1078 else { 1079 xc_entry_php_quick_resolve_opened_path(compiler, NULL TSRMLS_CC); 1080 1052 1081 compiler->new_entry.file_mtime = 0; 1053 1082 compiler->new_entry.file_size = 0; … … 1057 1086 #endif 1058 1087 } 1059 1060 if (!compiler->new_entry.file_inode) {1061 if (!compiler->opened_path) {1062 xc_entry_php_resolve_opened_path(compiler TSRMLS_CC);1063 }1064 }1065 1066 fprintf(stderr, "-------- %s\n", compiler->opened_path);1067 1088 1068 1089 { … … 1821 1842 xc_sandbox_t sandbox; 1822 1843 xc_cache_t *cache = xc_php_caches[compiler->entry_hash.cacheid]; 1844 struct stat statbuf; 1823 1845 1824 1846 /* stale clogs precheck */ … … 1832 1854 stored_php = NULL; 1833 1855 1834 if (compiler->opened_path) {1835 compiler->new_entry.entry.name.str.val = (char *) compiler->opened_path;1836 compiler->new_entry.entry.name.str.len = strlen(compiler->new_entry.entry.name.str.val);1837 }1838 else {1839 /* lookup in opened path */1840 }1841 1842 1856 ENTER_LOCK_EX(cache) { 1843 if ( XG(stat)) {1844 stored_entry = (xc_entry_php_t *) xc_entry_find_dmz(XC_TYPE_PHP, cache, compiler->entry_hash.entryslotid, (xc_entry_t *) &compiler->new_entry TSRMLS_CC);1857 if (!compiler->opened_path && xc_entry_find_include_path_dmz(compiler, compiler->filename, compiler->opened_path_buffer, &stored_entry TSRMLS_CC) == SUCCESS) { 1858 compiler->opened_path = compiler->opened_path_buffer; 1845 1859 } 1846 1860 else { 1861 if (!compiler->opened_path) { 1862 if (xc_entry_php_quick_resolve_opened_path(compiler, NULL TSRMLS_CC) == SUCCESS) { 1863 /* opened_path resolved */ 1864 } 1865 /* fall back to real stat call */ 1866 else if (xc_include_path_stat(compiler->filename, compiler->opened_path_buffer, &statbuf TSRMLS_CC) == SUCCESS) { 1867 compiler->opened_path = compiler->opened_path_buffer; 1868 } 1869 else { 1870 gaveup = 1; 1871 break; 1872 } 1873 } 1874 1875 /* finalize name */ 1847 1876 compiler->new_entry.entry.name.str.val = (char *) compiler->opened_path; 1848 1877 compiler->new_entry.entry.name.str.len = strlen(compiler->new_entry.entry.name.str.val); 1878 1879 stored_entry = (xc_entry_php_t *) xc_entry_find_dmz(XC_TYPE_PHP, cache, compiler->entry_hash.entryslotid, (xc_entry_t *) &compiler->new_entry TSRMLS_CC); 1849 1880 } 1850 1881 … … 1871 1902 compiler->new_entry.php = stored_php; 1872 1903 xc_php_addref_dmz(stored_php); 1873 if (!compiler->opened_path) {1874 xc_entry_php_resolve_opened_path(compiler TSRMLS_CC);1875 }1876 1904 xc_entry_php_init(&compiler->new_entry, compiler->opened_path TSRMLS_CC); 1877 1905 stored_entry = xc_entry_php_store_dmz(cache, compiler->entry_hash.entryslotid, &compiler->new_entry TSRMLS_CC); … … 1898 1926 1899 1927 /* found entry */ 1900 if (stored_entry ) {1928 if (stored_entry && stored_php) { 1901 1929 return xc_compile_restore(stored_entry, stored_php, h TSRMLS_CC); 1902 1930 }

