Changeset 870 in svn


Ignore:
Timestamp:
2012-03-30T09:45:26+02:00 (3 years ago)
Author:
Xuefer
Message:

get : include_path right or dont cache

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/xcache-test.ini

    r829 r870  
    88zend_extension=./modules/xcache.so
    99xcache.cacher = On
    10 xcache.test=1
     10xcache.test = 1
     11xcache.stat = 1
    1112xcache.experimental = On
    1213xcache.size = 16M
  • trunk/xcache.c

    r869 r870  
    897897
    898898#undef X_FREE
     899}
     900/* }}} */
     901static 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);
    899911}
    900912/* }}} */
     
    980992    xc_compiler_t *compiler = entry_find_include_path_data->compiler;
    981993
    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);
    983995    compiler->new_entry.entry.name.str.len = strlen(compiler->new_entry.entry.name.str.val);
    984996
     
    10181030        }
    10191031
    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);
    10211033        return SUCCESS;
    10221034    }
     
    10271039            return FAILURE;
    10281040        }
    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);
    10301042        return SUCCESS;
    10311043    }
     
    10451057        }
    10461058
    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);
    10481060        return SUCCESS;
    10491061    }
    10501062
     1063    return FAILURE;
     1064}
     1065/* }}} */
     1066static 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    }
    10511092    return FAILURE;
    10521093}
     
    10581099        time_t delta;
    10591100
    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) {
    10631103                return FAILURE;
    10641104            }
    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            }
    10661110        }
    10671111
     
    10981142            )
    10991143        {
    1100             const char *filename_end = compiler->filename + strlen(compiler->filename);
     1144            const char *filename_end = compiler->filename + compiler->filename_len;
    11011145            const char *basename = filename_end - 1;
    11021146
     
    18581902    ENTER_LOCK_EX(cache) {
    18591903        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;
    18611905        }
    18621906        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;
    18781910            }
    18791911
     
    20502082     || !h->filename
    20512083     || !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     ) {
    20532092        op_array = old_compile_file(h, type TSRMLS_CC);
    20542093        TRACE("%s", "cacher not enabled");
     
    20592098    compiler.opened_path = h->opened_path;
    20602099    compiler.filename = compiler.opened_path ? compiler.opened_path : h->filename;
     2100    compiler.filename_len = strlen(compiler.filename);
    20612101    if (xc_entry_php_init_key(&compiler TSRMLS_CC) != SUCCESS) {
    20622102        TRACE("failed to init key for %s", compiler.filename);
  • trunk/xcache.h

    r866 r870  
    465465typedef struct xc_compiler_t { /* {{{ */
    466466    const char *filename;
     467    size_t filename_len;
    467468    const char *opened_path;
    468469    char opened_path_buffer[MAXPATHLEN];
Note: See TracChangeset for help on using the changeset viewer.