Changeset 929 for trunk/xcache.c
- Timestamp:
- 06/26/2012 11:21:13 AM (11 months ago)
- Files:
-
- 1 modified
-
trunk/xcache.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/xcache.c
r925 r929 912 912 /* }}} */ 913 913 914 #define XC_ INCLUDE_PATH_XSTAT_FUNC(name) zend_bool name(const char *filepath, size_t filepath_len, void *data TSRMLS_DC)915 typedef XC_ INCLUDE_PATH_XSTAT_FUNC((*include_path_xstat_func_t));916 static zend_bool xc_ include_path_apply(const char *filepath, char *path_buffer, include_path_xstat_func_t xstat_func, void *data TSRMLS_DC) /* {{{ */914 #define XC_RESOLVE_PATH_CHECKER(name) zend_bool name(const char *filepath, size_t filepath_len, void *data TSRMLS_DC) 915 typedef XC_RESOLVE_PATH_CHECKER((*xc_resolve_path_checker_func_t)); 916 static zend_bool xc_resolve_path(const char *filepath, char *path_buffer, xc_resolve_path_checker_func_t checker_func, void *data TSRMLS_DC) /* {{{ */ 917 917 { 918 918 char *paths, *path; 919 919 char *tokbuf; 920 920 size_t path_buffer_len; 921 int size = strlen(PG(include_path)) + 1;921 int size; 922 922 char tokens[] = { DEFAULT_DIR_SEPARATOR, '\0' }; 923 923 int ret; 924 924 ALLOCA_FLAG(use_heap) 925 925 926 #if 0 927 if ((*filepath == '.' && 928 (IS_SLASH(filepath[1]) || 929 ((filepath[1] == '.') && IS_SLASH(filepath[2])))) || 930 IS_ABSOLUTE_PATH(filepath, strlen(filepath)) || 931 !path || 932 !*path) { 933 934 if (checker_func(path_buffer, path_buffer_len, data TSRMLS_CC)) { 935 ret = 1; 936 } 937 else { 938 ret = FAILURE; 939 } 940 goto finish; 941 } 942 #endif 943 944 size = strlen(PG(include_path)) + 1; 926 945 paths = (char *)my_do_alloca(size, use_heap); 927 946 memcpy(paths, PG(include_path), size); … … 930 949 path_buffer_len = snprintf(path_buffer, MAXPATHLEN, "%s/%s", path, filepath); 931 950 if (path_buffer_len < MAXPATHLEN - 1) { 932 if ( xstat_func(path_buffer, path_buffer_len, data TSRMLS_CC)) {951 if (checker_func(path_buffer, path_buffer_len, data TSRMLS_CC)) { 933 952 ret = 1; 934 953 goto finish; … … 952 971 path_buffer_len = dirname_len + filename_len; 953 972 path_buffer[path_buffer_len] = '\0'; 954 if ( xstat_func(path_buffer, path_buffer_len, data TSRMLS_CC) == 0) {973 if (checker_func(path_buffer, path_buffer_len, data TSRMLS_CC) == 0) { 955 974 ret = 1; 956 975 goto finish; … … 972 991 /* }}} */ 973 992 #ifndef ZEND_ENGINE_2_3 974 static XC_ INCLUDE_PATH_XSTAT_FUNC(xc_stat_file) /* {{{ */993 static XC_RESOLVE_PATH_CHECKER(xc_stat_file) /* {{{ */ 975 994 { 976 995 return VCWD_STAT(filepath, (struct stat *) data) == 0 ? 1 : 0; 977 996 } 978 997 /* }}} */ 979 static int xc_ include_path_stat(const char *filepath, char *path_buffer, struct stat *pbuf TSRMLS_DC) /* {{{ */980 { 981 return xc_ include_path_apply(filepath, path_buffer, xc_stat_file, (void *) pbuf TSRMLS_CC)998 static int xc_resolve_path_stat(const char *filepath, char *path_buffer, struct stat *pbuf TSRMLS_DC) /* {{{ */ 999 { 1000 return xc_resolve_path(filepath, path_buffer, xc_stat_file, (void *) pbuf TSRMLS_CC) 982 1001 ? SUCCESS 983 1002 : FAILURE; … … 985 1004 /* }}} */ 986 1005 #endif 987 typedef struct xc_entry_ find_include_path_data_t { /* {{{ */1006 typedef struct xc_entry_resolve_path_data_t { /* {{{ */ 988 1007 xc_compiler_t *compiler; 989 1008 xc_entry_php_t **stored_entry; 990 } xc_entry_ find_include_path_data_t;991 /* }}} */ 992 static XC_ INCLUDE_PATH_XSTAT_FUNC(xc_entry_find_include_path_func_unlocked) /* {{{ */993 { 994 xc_entry_ find_include_path_data_t *entry_find_include_path_data = (xc_entry_find_include_path_data_t *) data;995 xc_compiler_t *compiler = entry_ find_include_path_data->compiler;1009 } xc_entry_resolve_path_data_t; 1010 /* }}} */ 1011 static XC_RESOLVE_PATH_CHECKER(xc_entry_resolve_path_func_unlocked) /* {{{ */ 1012 { 1013 xc_entry_resolve_path_data_t *entry_resolve_path_data = (xc_entry_resolve_path_data_t *) data; 1014 xc_compiler_t *compiler = entry_resolve_path_data->compiler; 996 1015 997 1016 compiler->new_entry.entry.name.str.val = xc_expand_url(filepath, compiler->opened_path_buffer TSRMLS_CC); 998 1017 compiler->new_entry.entry.name.str.len = strlen(compiler->new_entry.entry.name.str.val); 999 1018 1000 *entry_ find_include_path_data->stored_entry = (xc_entry_php_t *) xc_entry_find_unlocked(1019 *entry_resolve_path_data->stored_entry = (xc_entry_php_t *) xc_entry_find_unlocked( 1001 1020 XC_TYPE_PHP 1002 1021 , xc_php_caches[compiler->entry_hash.cacheid] … … 1005 1024 TSRMLS_CC); 1006 1025 1007 return *entry_ find_include_path_data->stored_entry ? 1 : 0;1008 } 1009 /* }}} */ 1010 static int xc_entry_ find_include_path_unlocked(xc_compiler_t *compiler, const char *filepath, xc_entry_php_t **stored_entry TSRMLS_DC) /* {{{ */1026 return *entry_resolve_path_data->stored_entry ? 1 : 0; 1027 } 1028 /* }}} */ 1029 static int xc_entry_resolve_path_unlocked(xc_compiler_t *compiler, const char *filepath, xc_entry_php_t **stored_entry TSRMLS_DC) /* {{{ */ 1011 1030 { 1012 1031 char path_buffer[MAXPATHLEN]; 1013 xc_entry_ find_include_path_data_t entry_find_include_path_data;1014 entry_ find_include_path_data.compiler = compiler;1015 entry_ find_include_path_data.stored_entry = stored_entry;1016 1017 return xc_ include_path_apply(filepath, path_buffer, xc_entry_find_include_path_func_unlocked, (void *) &entry_find_include_path_data TSRMLS_CC)1032 xc_entry_resolve_path_data_t entry_resolve_path_data; 1033 entry_resolve_path_data.compiler = compiler; 1034 entry_resolve_path_data.stored_entry = stored_entry; 1035 1036 return xc_resolve_path(filepath, path_buffer, xc_entry_resolve_path_func_unlocked, (void *) &entry_resolve_path_data TSRMLS_CC) 1018 1037 ? SUCCESS 1019 1038 : FAILURE; … … 1027 1046 struct stat *sapi_stat = sapi_get_stat(TSRMLS_C); 1028 1047 if (!sapi_stat) { 1029 return FAILURE; 1030 } 1031 1048 goto giveupsapistat; 1049 } 1032 1050 *statbuf = *sapi_stat; 1033 1051 } 1034 1052 1035 compiler->opened_path = xc_expand_url( SG(request_info).path_translated, compiler->opened_path_buffer TSRMLS_CC);1053 compiler->opened_path = xc_expand_url(compiler->filename, compiler->opened_path_buffer TSRMLS_CC); 1036 1054 return SUCCESS; 1037 1055 } 1056 giveupsapistat: 1038 1057 1039 1058 /* absolute path */ … … 1087 1106 #else 1088 1107 char path_buffer[MAXPATHLEN]; 1089 if (xc_ include_path_stat(compiler->filename, path_buffer, statbuf TSRMLS_CC) == SUCCESS) {1108 if (xc_resolve_path_stat(compiler->filename, path_buffer, statbuf TSRMLS_CC) == SUCCESS) { 1090 1109 compiler->opened_path = xc_expand_url(path_buffer, compiler->opened_path_buffer TSRMLS_CC); 1091 1110 return SUCCESS; … … 1911 1930 1912 1931 ENTER_LOCK_EX(cache) { 1913 if (!compiler->opened_path && xc_entry_ find_include_path_unlocked(compiler, compiler->filename, &stored_entry TSRMLS_CC) == SUCCESS) {1932 if (!compiler->opened_path && xc_entry_resolve_path_unlocked(compiler, compiler->filename, &stored_entry TSRMLS_CC) == SUCCESS) { 1914 1933 compiler->opened_path = compiler->new_entry.entry.name.str.val; 1915 1934 } … … 3860 3879 static PHP_MSHUTDOWN_FUNCTION(xcache) 3861 3880 { 3881 #ifdef HAVE_XCACHE_COVERAGER 3882 xc_coverager_destroy(); 3883 #endif 3884 xc_util_destroy(); 3885 3862 3886 if (xc_initized) { 3863 3887 xc_destroy(); … … 3871 3895 xc_shm_scheme = NULL; 3872 3896 } 3873 3874 #ifdef HAVE_XCACHE_COVERAGER3875 xc_coverager_destroy();3876 #endif3877 xc_util_destroy();3878 3897 3879 3898 if (xc_coredump_dir && xc_coredump_dir[0]) {

