Changeset 540 for trunk/xcache.c


Ignore:
Timestamp:
2008-03-02T08:52:34+01:00 (6 years ago)
Author:
moo
Message:

fixed #83: hash files with same basename into same cache split for better uniq cache

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xcache.c

    r537 r540  
    1919#include "ext/standard/md5.h" 
    2020#include "ext/standard/php_math.h" 
     21#include "ext/standard/php_string.h" 
    2122#include "zend_extensions.h" 
    2223#include "SAPI.h" 
     
    857858} 
    858859/* }}} */ 
     860static inline xc_hash_value_t xc_entry_hash_php_basename(xc_entry_t *xce TSRMLS_DC) /* {{{ */ 
     861{ 
     862#ifdef IS_UNICODE 
     863    if (UG(unicode) && xce->name_type == IS_UNICODE) { 
     864        UChar *basename; 
     865        int basename_len; 
     866        php_u_basename(xce->name.uni.val, xce->name.uni.len, NULL_ZSTR, 0, &basename, &basename_len TSRMLS_CC); 
     867        return HASH_USTR_L(IS_UNICODE, basename, basename_len); 
     868    } 
     869    else 
     870#endif 
     871    { 
     872        char *basename; 
     873        UNISW(size_t, int) basename_len; 
     874        php_basename(xce->name.str.val, xce->name.str.len, "", 0, &basename, &basename_len TSRMLS_CC); 
     875        return HASH_STR_L(basename, basename_len); 
     876    } 
     877} 
     878/* }}} */ 
    859879static int xc_entry_init_key_php(xc_entry_t *xce, char *filename, char *opened_path_buffer TSRMLS_DC) /* {{{ */ 
    860880{ 
     
    955975    xce->name.str.len = strlen(filename); 
    956976 
     977    if (xc_php_hcache.size > 1) { 
     978        hv = xc_entry_hash_php_basename(xce TSRMLS_CC); 
     979        cacheid = xc_hash_fold(hv, &xc_php_hcache); 
     980    } 
     981    else { 
     982        cacheid = 0; 
     983    } 
     984    xce->cache = xc_php_caches[cacheid]; 
     985 
    957986    hv = xc_entry_hash_php(xce TSRMLS_CC); 
    958     cacheid = xc_hash_fold(hv, &xc_php_hcache); 
    959     xce->cache = xc_php_caches[cacheid]; 
    960987    xce->hvalue = xc_hash_fold(hv, &xc_php_hentry); 
    961988 
Note: See TracChangeset for help on using the changeset viewer.