Changeset 867


Ignore:
Timestamp:
2012-03-29T17:41:11+02:00 (3 years ago)
Author:
moo
Message:

include path lookup in cache

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xcache.c

    r866 r867  
    901901 
    902902#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) /* {{{ */ 
     903typedef XC_INCLUDE_PATH_XSTAT_FUNC((*include_path_xstat_func_t)); 
     904static zend_bool xc_include_path_apply(const char *filepath, char *opened_path_buffer, include_path_xstat_func_t xstat_func, void *data TSRMLS_DC) /* {{{ */ 
    905905{ 
    906906    char *paths, *path; 
     
    963963} 
    964964/* }}} */ 
    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) 
     965static 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) 
    968968        ? SUCCESS 
    969969        : FAILURE; 
    970970} 
    971971/* }}} */ 
    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; 
     972typedef 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/* }}} */ 
     977static 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/* }}} */ 
     995static 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; 
    9771004} 
    9781005/* }}} */ 
     
    10311058 
    10321059        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) { 
    10341061                return FAILURE; 
    10351062            } 
     
    10491076#endif 
    10501077    } 
    1051     else { /* XG(inode) */ 
     1078    else { 
     1079        xc_entry_php_quick_resolve_opened_path(compiler, NULL TSRMLS_CC); 
     1080 
    10521081        compiler->new_entry.file_mtime   = 0; 
    10531082        compiler->new_entry.file_size    = 0; 
     
    10571086#endif 
    10581087    } 
    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); 
    10671088 
    10681089    { 
     
    18211842    xc_sandbox_t sandbox; 
    18221843    xc_cache_t *cache = xc_php_caches[compiler->entry_hash.cacheid]; 
     1844    struct stat statbuf; 
    18231845 
    18241846    /* stale clogs precheck */ 
     
    18321854    stored_php = NULL; 
    18331855 
    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  
    18421856    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; 
    18451859        } 
    18461860        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 */ 
    18471876            compiler->new_entry.entry.name.str.val = (char *) compiler->opened_path; 
    18481877            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); 
    18491880        } 
    18501881 
     
    18711902            compiler->new_entry.php = stored_php; 
    18721903            xc_php_addref_dmz(stored_php); 
    1873             if (!compiler->opened_path) { 
    1874                 xc_entry_php_resolve_opened_path(compiler TSRMLS_CC); 
    1875             } 
    18761904            xc_entry_php_init(&compiler->new_entry, compiler->opened_path TSRMLS_CC); 
    18771905            stored_entry = xc_entry_php_store_dmz(cache, compiler->entry_hash.entryslotid, &compiler->new_entry TSRMLS_CC); 
     
    18981926 
    18991927    /* found entry */ 
    1900     if (stored_entry) { 
     1928    if (stored_entry && stored_php) { 
    19011929        return xc_compile_restore(stored_entry, stored_php, h TSRMLS_CC); 
    19021930    } 
Note: See TracChangeset for help on using the changeset viewer.