Changeset 964 in svn


Ignore:
Timestamp:
2012-07-13T04:40:55+02:00 (3 years ago)
Author:
Xuefer
Message:

fixed #264, #284: FILE DIR handling for moved/hardlinked files (set "xcache.experimental = on" to eanble this fix)

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r962 r964  
    99 * fixed #283: XCache admin APIs (admin page) cause SEGV if XCache failed to initize
    1010 * fixed possible re-include a file by mixing include/include_once
     11 * fixed #264, #284: __FILE__ __DIR__ handling for moved/hardlinked files (set "xcache.experimental = on" to eanble this fix)
    1112
    12132.0.0 2012-04-20
  • trunk/NEWS

    r943 r964  
    44 * admin/ config changed. please update accordingly
    55 * PHP 5.3.14 is unstable. Please upgrade to new version. You have been warned
     6 * fixed __FILE__ __DIR__ handling for moved/hardlinked files (set "xcache.experimental = on" to eanble this fix)
    67
    782.0.0 2012-04-20
  • trunk/processor/processor.m4

    r930 r964  
    11651165    PROCESS(time_t, file_mtime)
    11661166    PROCESS(size_t, file_size)
    1167 #ifdef HAVE_INODE
    11681167    PROCESS(int, file_device)
    11691168    PROCESS(int, file_inode)
    1170 #endif
    11711169
    11721170    PROCESS(int, filepath_len)
  • trunk/xcache.c

    r961 r964  
    189189    switch (type) {
    190190        case XC_TYPE_PHP:
    191 #ifdef HAVE_INODE
    192191            {
    193192                const xc_entry_php_t *php_entry1 = (const xc_entry_php_t *) entry1;
    194193                const xc_entry_php_t *php_entry2 = (const xc_entry_php_t *) entry2;
    195                 if (php_entry1->file_inode) {
    196                     return php_entry1->file_inode == php_entry2->file_inode
    197                         && php_entry1->file_device == php_entry2->file_device;
     194                if (php_entry1->file_inode && php_entry2->file_inode) {
     195                    zend_bool inodeIsSame = php_entry1->file_inode == php_entry2->file_inode
     196                                         && php_entry1->file_device == php_entry2->file_device;
     197                    if (XG(experimental)) {
     198                        /* new experimental behavior: quick check by inode, first */
     199                        if (!inodeIsSame) {
     200                            return 0;
     201                        }
     202
     203                        /* and then opened_path compare */
     204                    }
     205                    else {
     206                        /* old behavior: inode check only */
     207                        return inodeIsSame;
     208                    }
    198209                }
    199210            }
    200 #endif
     211
    201212            assert(IS_ABSOLUTE_PATH(entry1->name.str.val, entry1->name.str.len));
    202213            assert(IS_ABSOLUTE_PATH(entry2->name.str.val, entry2->name.str.len));
    203214
    204             if (entry1->name.str.len != entry2->name.str.len) {
    205                 return 0;
    206             }
    207             return memcmp(entry1->name.str.val, entry2->name.str.val, entry1->name.str.len + 1) == 0;
     215            return entry1->name.str.len == entry2->name.str.len
     216                && memcmp(entry1->name.str.val, entry2->name.str.val, entry1->name.str.len + 1) == 0;
    208217
    209218        case XC_TYPE_VAR:
     
    212221                return 0;
    213222            }
    214             else if (entry1->name_type == IS_UNICODE) {
    215                 if (entry1->name.ustr.len != entry2->name.ustr.len) {
    216                     return 0;
    217                 }
    218                 return memcmp(entry1->name.ustr.val, entry2->name.ustr.val, (entry1->name.ustr.len + 1) * sizeof(UChar)) == 0;
    219             }
    220             else
    221 #endif
    222             {
    223                 if (entry1->name.str.len != entry2->name.str.len) {
    224                     return 0;
    225                 }
    226                 return memcmp(entry1->name.str.val, entry2->name.str.val, entry1->name.str.len + 1) == 0;
    227             }
     223
     224            if (entry1->name_type == IS_UNICODE) {
     225                return entry1->name.ustr.len == entry2->name.ustr.len
     226                    && memcmp(entry1->name.ustr.val, entry2->name.ustr.val, (entry1->name.ustr.len + 1) * sizeof(UChar)) == 0;
     227            }
     228#endif
     229            return entry1->name.str.len == entry2->name.str.len
     230                && memcmp(entry1->name.str.val, entry2->name.str.val, entry1->name.str.len + 1) == 0;
    228231            break;
    229232
     
    693696            add_assoc_long_ex(ei, ZEND_STRS("file_mtime"),    entry_php->file_mtime);
    694697            add_assoc_long_ex(ei, ZEND_STRS("file_size"),     entry_php->file_size);
    695 #ifdef HAVE_INODE
    696698            add_assoc_long_ex(ei, ZEND_STRS("file_device"),   entry_php->file_device);
    697699            add_assoc_long_ex(ei, ZEND_STRS("file_inode"),    entry_php->file_inode);
    698 #endif
    699700
    700701#ifdef HAVE_XCACHE_CONSTANT
     
    11541155        compiler->new_entry.file_mtime   = buf.st_mtime;
    11551156        compiler->new_entry.file_size    = buf.st_size;
    1156 #ifdef HAVE_INODE
    11571157        compiler->new_entry.file_device  = buf.st_dev;
    11581158        compiler->new_entry.file_inode   = buf.st_ino;
    1159 #endif
    11601159    }
    11611160    else {
     
    11641163        compiler->new_entry.file_mtime   = 0;
    11651164        compiler->new_entry.file_size    = 0;
    1166 #ifdef HAVE_INODE
    11671165        compiler->new_entry.file_device  = 0;
    11681166        compiler->new_entry.file_inode   = 0;
    1169 #endif
    11701167    }
    11711168
    11721169    {
    11731170        xc_hash_value_t basename_hash_value;
    1174         if (
    1175             xc_php_hcache.size > 1
    1176 #ifdef HAVE_INODE
    1177             || !compiler->new_entry.file_inode
    1178 #endif
    1179             )
    1180         {
     1171        if (xc_php_hcache.size > 1
     1172         || !compiler->new_entry.file_inode) {
    11811173            const char *filename_end = compiler->filename + compiler->filename_len;
    11821174            const char *basename = filename_end - 1;
     
    11941186        compiler->entry_hash.cacheid = xc_php_hcache.size > 1 ? xc_hash_fold(basename_hash_value, &xc_php_hcache) : 0;
    11951187        compiler->entry_hash.entryslotid = xc_hash_fold(
    1196 #ifdef HAVE_INODE
    11971188                compiler->new_entry.file_inode
    11981189                ? HASH(compiler->new_entry.file_device + compiler->new_entry.file_inode)
    1199                 :
    1200 #endif
    1201                 basename_hash_value
     1190                : basename_hash_value
    12021191                , &xc_php_hentry);
    12031192    }
  • trunk/xcache.h

    r958 r964  
    2323#include "lock.h"
    2424
    25 #define HAVE_INODE
    2625#if !defined(ZEND_ENGINE_2_4) && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4 || PHP_MAJOR_VERSION > 5)
    2726#   define ZEND_ENGINE_2_4
     
    434433    time_t file_mtime;
    435434    size_t file_size;
    436 #ifdef HAVE_INODE
    437435    int file_device;
    438436    int file_inode;
    439 #endif
    440437
    441438    int    filepath_len;
Note: See TracChangeset for help on using the changeset viewer.