Changeset 929


Ignore:
Timestamp:
2012-06-26T11:21:13+02:00 (3 years ago)
Author:
moo
Message:

xc_resolve_path for better name. call util/coverager destroy first

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xcache.c

    r925 r929  
    912912/* }}} */
    913913
    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)
     915typedef XC_RESOLVE_PATH_CHECKER((*xc_resolve_path_checker_func_t));
     916static zend_bool xc_resolve_path(const char *filepath, char *path_buffer, xc_resolve_path_checker_func_t checker_func, void *data TSRMLS_DC) /* {{{ */
    917917{
    918918    char *paths, *path;
    919919    char *tokbuf;
    920920    size_t path_buffer_len;
    921     int size = strlen(PG(include_path)) + 1;
     921    int size;
    922922    char tokens[] = { DEFAULT_DIR_SEPARATOR, '\0' };
    923923    int ret;
    924924    ALLOCA_FLAG(use_heap)
    925925
     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;
    926945    paths = (char *)my_do_alloca(size, use_heap);
    927946    memcpy(paths, PG(include_path), size);
     
    930949        path_buffer_len = snprintf(path_buffer, MAXPATHLEN, "%s/%s", path, filepath);
    931950        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)) {
    933952                ret = 1;
    934953                goto finish;
     
    952971                        path_buffer_len = dirname_len + filename_len;
    953972                        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) {
    955974                            ret = 1;
    956975                            goto finish;
     
    972991/* }}} */
    973992#ifndef ZEND_ENGINE_2_3
    974 static XC_INCLUDE_PATH_XSTAT_FUNC(xc_stat_file) /* {{{ */
     993static XC_RESOLVE_PATH_CHECKER(xc_stat_file) /* {{{ */
    975994{
    976995    return VCWD_STAT(filepath, (struct stat *) data) == 0 ? 1 : 0;
    977996}
    978997/* }}} */
    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)
     998static 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)
    9821001        ? SUCCESS
    9831002        : FAILURE;
     
    9851004/* }}} */
    9861005#endif
    987 typedef struct xc_entry_find_include_path_data_t { /* {{{ */
     1006typedef struct xc_entry_resolve_path_data_t { /* {{{ */
    9881007    xc_compiler_t *compiler;
    9891008    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/* }}} */
     1011static 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;
    9961015
    9971016    compiler->new_entry.entry.name.str.val = xc_expand_url(filepath, compiler->opened_path_buffer TSRMLS_CC);
    9981017    compiler->new_entry.entry.name.str.len = strlen(compiler->new_entry.entry.name.str.val);
    9991018
    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(
    10011020            XC_TYPE_PHP
    10021021            , xc_php_caches[compiler->entry_hash.cacheid]
     
    10051024            TSRMLS_CC);
    10061025
    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/* }}} */
     1029static int xc_entry_resolve_path_unlocked(xc_compiler_t *compiler, const char *filepath, xc_entry_php_t **stored_entry TSRMLS_DC) /* {{{ */
    10111030{
    10121031    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)
    10181037        ? SUCCESS
    10191038        : FAILURE;
     
    10271046            struct stat *sapi_stat = sapi_get_stat(TSRMLS_C);
    10281047            if (!sapi_stat) {
    1029                 return FAILURE;
    1030             }
    1031 
     1048                goto giveupsapistat;
     1049            }
    10321050            *statbuf = *sapi_stat;
    10331051        }
    10341052
    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);
    10361054        return SUCCESS;
    10371055    }
     1056giveupsapistat:
    10381057
    10391058    /* absolute path */
     
    10871106#else
    10881107        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) {
    10901109            compiler->opened_path = xc_expand_url(path_buffer, compiler->opened_path_buffer TSRMLS_CC);
    10911110            return SUCCESS;
     
    19111930
    19121931    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) {
    19141933            compiler->opened_path = compiler->new_entry.entry.name.str.val;
    19151934        }
     
    38603879static PHP_MSHUTDOWN_FUNCTION(xcache)
    38613880{
     3881#ifdef HAVE_XCACHE_COVERAGER
     3882    xc_coverager_destroy();
     3883#endif
     3884    xc_util_destroy();
     3885
    38623886    if (xc_initized) {
    38633887        xc_destroy();
     
    38713895        xc_shm_scheme = NULL;
    38723896    }
    3873 
    3874 #ifdef HAVE_XCACHE_COVERAGER
    3875     xc_coverager_destroy();
    3876 #endif
    3877     xc_util_destroy();
    38783897
    38793898    if (xc_coredump_dir && xc_coredump_dir[0]) {
Note: See TracChangeset for help on using the changeset viewer.