Changeset 311

Show
Ignore:
Timestamp:
12/09/2006 04:27:03 PM (2 years ago)
Author:
moo
Message:

restruct cached compile, add md5 table to recognize and merge file with same content

Location:
trunk
Files:
2 added
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/processor/dispatch.m4

    r1 r311  
    2323    , `$1', `xc_entry_type_t',  `PROC_INT(`$2', `d',  `$1')' 
    2424    , `$1', `xc_hash_value_t',  `PROC_INT(`$2', `lu', `$1')' 
     25    , `$1', `xc_md5sum_t',      `/* is copying enough? */COPY(`$2')' 
    2526    , `', `', `m4_errprint(`Unknown type "$1"')' 
    2627    ) 
  • trunk/processor/head.m4

    r300 r311  
    6565    zend_bool reference; /* enable if to deal with reference */ 
    6666    zend_bool have_references; 
    67     const xc_entry_t *xce_src; 
    68     const xc_entry_t *xce_dst; 
     67    const xc_entry_data_php_t *php_src; 
     68    const xc_entry_data_php_t *php_dst; 
     69    const xc_cache_t          *cache; 
    6970    const zend_class_entry *cache_ce; 
    7071    zend_uint cache_class_num; 
     
    186187static zend_ulong xc_get_class_num(xc_processor_t *processor, zend_class_entry *ce) { 
    187188    zend_ulong i; 
    188     const xc_entry_t *xce = processor->xce_src; 
     189    const xc_entry_data_php_t *php = processor->php_src; 
    189190    zend_class_entry *ceptr; 
    190191 
     
    192193        return processor->cache_class_num; 
    193194    } 
    194     for (i = 0; i < xce->data.php->classinfo_cnt; i ++) { 
    195         ceptr = CestToCePtr(xce->data.php->classinfos[i].cest); 
     195    for (i = 0; i < php->classinfo_cnt; i ++) { 
     196        ceptr = CestToCePtr(php->classinfos[i].cest); 
    196197        if (ZCEP_REFCOUNT_PTR(ceptr) == ZCEP_REFCOUNT_PTR(ce)) { 
    197198            processor->cache_ce = ceptr; 
     
    209210    /* must be parent or currrent class */ 
    210211    assert(class_num <= processor->active_class_num); 
    211     return CestToCePtr(processor->xce_dst->data.php->classinfos[class_num - 1].cest); 
     212    return CestToCePtr(processor->php_dst->classinfos[class_num - 1].cest); 
    212213} 
    213214#endif 
     
    275276/* }}} */ 
    276277dnl ================ export API 
    277 /* export: xc_entry_t *xc_processor_store_xc_entry_t(xc_entry_t *src TSRMLS_DC); :export {{{ */ 
    278 xc_entry_t *xc_processor_store_xc_entry_t(xc_entry_t *src TSRMLS_DC) { 
    279     xc_entry_t *dst; 
     278define(`DEFINE_STORE_API', ` 
     279/* export: $1 *xc_processor_store_$1($1 *src TSRMLS_DC); :export {{{ */ 
     280$1 *xc_processor_store_$1($1 *src TSRMLS_DC) { 
     281    $1 *dst; 
    280282    xc_processor_t processor; 
    281283 
    282284    memset(&processor, 0, sizeof(processor)); 
    283285    processor.reference = 1; 
     286    processor.cache = src->cache; 
    284287 
    285288    IFASSERT(`xc_stack_init(&processor.allocsizes);') 
     
    295298        processor.size = ALIGN(processor.size + sizeof(src[0])); 
    296299 
    297         xc_calc_xc_entry_t(&processor, src TSRMLS_CC); 
     300        xc_calc_$1(&processor, src TSRMLS_CC); 
    298301        if (processor.reference) { 
    299302            zend_hash_destroy(&processor.zvalptrs); 
     
    302305    } 
    303306    src->size = processor.size; 
    304     src->have_references = processor.have_references; 
     307    ifelse(`$1', `xc_entry_t', ` 
     308        src->data.var->have_references = processor.have_references; 
     309    ', ` 
     310        src->have_references = processor.have_references; 
     311    ') 
    305312 
    306313    IFASSERT(`xc_stack_reverse(&processor.allocsizes);') 
     
    314321 
    315322        /* mem :) */ 
    316         processor.p = (char *) src->cache->mem->handlers->malloc(src->cache->mem, processor.size); 
     323        processor.p = (char *) processor.cache->mem->handlers->malloc(processor.cache->mem, processor.size); 
    317324        if (processor.p == NULL) { 
    318325            dst = NULL; 
     
    323330 
    324331        /* allocate */ 
    325         dst = (xc_entry_t *) processor.p; 
     332        dst = ($1 *) processor.p; 
    326333        processor.p = (char *) ALIGN(processor.p + sizeof(dst[0])); 
    327334 
    328         xc_store_xc_entry_t(&processor, dst, src TSRMLS_CC); 
     335        xc_store_$1(&processor, dst, src TSRMLS_CC); 
    329336        IFASSERT(` { 
    330337            int real = processor.p - oldp; 
     
    348355} 
    349356/* }}} */ 
    350 /* export: xc_entry_t *xc_processor_restore_xc_entry_t(xc_entry_t *dst, const xc_entry_t *src, zend_bool readonly_protection TSRMLS_DC); :export {{{ */ 
    351 xc_entry_t *xc_processor_restore_xc_entry_t(xc_entry_t *dst, const xc_entry_t *src, zend_bool readonly_protection TSRMLS_DC) { 
     357') 
     358DEFINE_STORE_API(`xc_entry_t') 
     359DEFINE_STORE_API(`xc_entry_data_php_t') 
     360/* export: xc_entry_t *xc_processor_restore_xc_entry_t(xc_entry_t *dst, const xc_entry_t *src TSRMLS_DC); :export {{{ */ 
     361xc_entry_t *xc_processor_restore_xc_entry_t(xc_entry_t *dst, const xc_entry_t *src TSRMLS_DC) { 
     362    xc_processor_t processor; 
     363 
     364    memset(&processor, 0, sizeof(processor)); 
     365    xc_restore_xc_entry_t(&processor, dst, src TSRMLS_CC); 
     366 
     367    return dst; 
     368} 
     369/* }}} */ 
     370/* export: xc_entry_data_php_t *xc_processor_restore_xc_entry_data_php_t(xc_entry_data_php_t *dst, const xc_entry_data_php_t *src, zend_bool readonly_protection TSRMLS_DC); :export {{{ */ 
     371xc_entry_data_php_t *xc_processor_restore_xc_entry_data_php_t(xc_entry_data_php_t *dst, const xc_entry_data_php_t *src, zend_bool readonly_protection TSRMLS_DC) { 
    352372    xc_processor_t processor; 
    353373 
    354374    memset(&processor, 0, sizeof(processor)); 
    355375    processor.readonly_protection = readonly_protection; 
     376    /* this function is used for php data only */ 
    356377    if (src->have_references) { 
    357378        processor.reference = 1; 
     
    361382        zend_hash_init(&processor.zvalptrs, 0, NULL, NULL, 0); 
    362383    } 
    363     xc_restore_xc_entry_t(&processor, dst, src TSRMLS_CC); 
     384    xc_restore_xc_entry_data_php_t(&processor, dst, src TSRMLS_CC); 
    364385    if (processor.reference) { 
    365386        zend_hash_destroy(&processor.zvalptrs); 
  • trunk/processor/main.m4

    r307 r311  
    136136define(`FIXPOINTER', `FIXPOINTER_EX(`$1', `dst->$2')') 
    137137define(`FIXPOINTER_EX', `IFSTORE(` 
    138     $2 = ($1 *) processor->xce_src->cache->shm->handlers->to_readonly(processor->xce_src->cache->shm, (char *)$2); 
     138    $2 = ($1 *) processor->cache->shm->handlers->to_readonly(processor->cache->shm, (char *)$2); 
    139139')') 
    140140define(`UNFIXPOINTER', `UNFIXPOINTER_EX(`$1', `dst->$2')') 
    141141define(`UNFIXPOINTER_EX', `IFSTORE(` 
    142     $2 = ($1 *) processor->xce_src->cache->shm->handlers->to_readwrite(processor->xce_src->cache->shm, (char *)$2); 
     142    $2 = ($1 *) processor->cache->shm->handlers->to_readwrite(processor->cache->shm, (char *)$2); 
    143143')') 
    144144dnl }}} 
    145145dnl {{{ COPY 
    146146define(`COPY', `IFNOTMEMCPY(`IFCOPY(`dst->$1 = src->$1;')')DONE(`$1')') 
     147dnl }}} 
     148dnl {{{ COPYPOINTER 
     149define(`COPYPOINTER', `COPY(`$1')') 
     150dnl }}} 
     151dnl {{{ COPYARRAY 
     152define(`COPYARRAY', `IFNOTMEMCPY(`IFCOPY(`memcpy(dst->$1, src->$1, sizeof(dst->$1));')')DONE(`$1')') 
    147153dnl }}} 
    148154dnl {{{ SETNULL_EX 
     
    223229EXPORT(`xc_funcinfo_t') 
    224230EXPORT(`xc_entry_t') 
     231EXPORT(`xc_entry_data_php_t') 
    225232EXPORT(`zval') 
    226233 
  • trunk/processor/processor.m4

    r310 r311  
    479479    dnl readonly_protection=on 
    480480    dnl main op_array && have early binding 
    481     if (!processor->readonly_protection && !(src == processor->xce_src->data.php->op_array && processor->xce_src->data.php->have_early_binding)) { 
     481    if (!processor->readonly_protection && !(src == processor->php_src->op_array && processor->php_src->have_early_binding)) { 
    482482        /* really fast shallow copy */ 
    483483        memcpy(dst, src, sizeof(src[0])); 
     
    719719    zend_uint i; 
    720720 
    721 #ifdef HAVE_INODE 
    722     DISPATCH(int, device) 
    723     DISPATCH(int, inode) 
    724 #endif 
     721    IFCOPY(` 
     722        processor->php_dst = dst; 
     723        processor->php_src = src; 
     724    ') 
     725 
     726    DISPATCH(xc_hash_value_t, hvalue) 
     727    /* skip */ 
     728    DONE(next) 
     729    COPY(cache) 
     730    DISPATCH(xc_md5sum_t, md5) 
     731    DISPATCH(zend_ulong, refcount) 
     732 
    725733    DISPATCH(size_t, sourcesize) 
    726  
    727     DISPATCH(time_t, mtime) 
     734    DISPATCH(zend_ulong, hits) 
     735    DISPATCH(size_t, size) 
    728736 
    729737    STRUCT_P(zend_op_array, op_array) 
     
    750758    DISPATCH(zend_bool, have_early_binding) 
    751759    popdef(`BEFORE_LOOP') 
     760    DISPATCH(zend_bool, have_references) 
    752761') 
    753762dnl }}} 
     
    755764    IFDPRINT(`INDENT()`'fprintf(stderr, "zval:value");') 
    756765    STRUCT_P_EX(zval_ptr, dst->value, src->value, `value', `', `&') 
     766    DISPATCH(zend_bool, have_references) 
    757767    DONE(value) 
    758768') 
     
    760770dnl {{{ xc_entry_t 
    761771DEF_STRUCT_P_FUNC(`xc_entry_t', , ` 
    762     IFCOPY(` 
    763         processor->xce_dst = dst; 
    764         processor->xce_src = src; 
    765     ') 
    766772    DISPATCH(xc_entry_type_t, type) 
    767773    DISPATCH(size_t, size) 
     
    809815        switch (src->type) { 
    810816        case XC_TYPE_PHP: 
    811             STRUCT_P(xc_entry_data_php_t, data.php) 
     817            IFCALCCOPY(`DONE(data.php)', `STRUCT_P(xc_entry_data_php_t, data.php)') 
    812818            break; 
     819 
    813820        case XC_TYPE_VAR: 
    814821            STRUCT_P(xc_entry_data_var_t, data.var) 
    815822            break; 
     823 
    816824        default: 
    817825            assert(0); 
     
    820828    DONE(data) 
    821829    dnl }}} 
    822     DISPATCH(zend_bool, have_references) 
     830    DISPATCH(time_t, mtime) 
     831#ifdef HAVE_INODE 
     832    DISPATCH(int, device) 
     833    DISPATCH(int, inode) 
     834#endif 
    823835') 
    824836dnl }}} 
  • trunk/xcache.c

    r307 r311  
    106106/* any function in *_dmz is only safe be called within locked(single thread) area */ 
    107107 
     108static void xc_php_add_dmz(xc_entry_data_php_t *php) /* {{{ */ 
     109{ 
     110    xc_entry_data_php_t **head = &(php->cache->phps[php->hvalue]); 
     111    php->next = *head; 
     112    *head = php; 
     113    php->cache->phps_count ++; 
     114} 
     115/* }}} */ 
     116static xc_entry_data_php_t *xc_php_store_dmz(xc_entry_data_php_t *php TSRMLS_DC) /* {{{ */ 
     117{ 
     118    xc_entry_data_php_t *stored_php; 
     119 
     120    php->hits     = 0; 
     121    php->refcount = 0; 
     122    stored_php = xc_processor_store_xc_entry_data_php_t(php TSRMLS_CC); 
     123    if (stored_php) { 
     124        xc_php_add_dmz(stored_php); 
     125        return stored_php; 
     126    } 
     127    else { 
     128        php->cache->ooms ++; 
     129        return NULL; 
     130    } 
     131} 
     132/* }}} */ 
     133static xc_entry_data_php_t *xc_php_find_dmz(xc_entry_data_php_t *php TSRMLS_DC) /* {{{ */ 
     134{ 
     135    xc_entry_data_php_t *p; 
     136    for (p = php->cache->phps[php->hvalue]; p; p = p->next) { 
     137        if (memcmp(php->md5, p->md5, sizeof(php->md5)) == 0) { 
     138            p->hits ++; 
     139            return p; 
     140        } 
     141    } 
     142    return NULL; 
     143} 
     144/* }}} */ 
     145static void xc_php_free_dmz(xc_entry_data_php_t *php) /* {{{ */ 
     146{ 
     147    php->cache->mem->handlers->free(php->cache->mem, (xc_entry_data_php_t *)php); 
     148} 
     149/* }}} */ 
     150static void xc_php_remove_dmz(xc_entry_data_php_t *php) /* {{{ */ 
     151{ 
     152    if (-- php->refcount == 0) { 
     153        xc_entry_data_php_t **pp = &(php->cache->phps[php->hvalue]); 
     154        xc_entry_data_php_t *p; 
     155        for (p = *pp; p; pp = &(p->next), p = p->next) { 
     156            if (memcmp(php->md5, p->md5, sizeof(php->md5)) == 0) { 
     157                /* unlink */ 
     158                *pp = p->next; 
     159                xc_php_free_dmz(php); 
     160                return; 
     161            } 
     162        } 
     163        assert(0); 
     164    } 
     165} 
     166/* }}} */ 
     167 
    108168static inline int xc_entry_equal_dmz(xc_entry_t *a, xc_entry_t *b) /* {{{ */ 
    109169{ 
     
    117177#ifdef HAVE_INODE 
    118178            do { 
    119                 xc_entry_data_php_t *ap = a->data.php; 
    120                 xc_entry_data_php_t *bp = b->data.php; 
    121                 if (ap->inode) { 
    122                     return ap->inode == bp->inode 
    123                         && ap->device == bp->device; 
     179                if (a->inode) { 
     180                    return a->inode == b->inode 
     181                        && a->device == b->device; 
    124182                } 
    125183            } while(0); 
     
    150208} 
    151209/* }}} */ 
    152 static void xc_entry_free_real_dmz(volatile xc_entry_t *xce) /* {{{ */ 
    153 { 
    154     xce->cache->mem->handlers->free(xce->cache->mem, (xc_entry_t *)xce); 
    155 } 
    156 /* }}} */ 
    157210static void xc_entry_add_dmz(xc_entry_t *xce) /* {{{ */ 
    158211{ 
     
    179232        return NULL; 
    180233    } 
     234} 
     235/* }}} */ 
     236static void xc_entry_free_real_dmz(volatile xc_entry_t *xce) /* {{{ */ 
     237{ 
     238    if (xce->type == XC_TYPE_PHP) { 
     239        xc_php_remove_dmz(xce->data.php); 
     240    } 
     241    xce->cache->mem->handlers->free(xce->cache->mem, (xc_entry_t *)xce); 
    181242} 
    182243/* }}} */ 
     
    216277    for (p = xce->cache->entries[xce->hvalue]; p; p = p->next) { 
    217278        if (xc_entry_equal_dmz(xce, p)) { 
    218             if (p->type == XC_TYPE_VAR || /* PHP */ p->data.php->mtime == xce->data.php->mtime) { 
     279            if (p->type == XC_TYPE_VAR || /* PHP */ p->mtime == xce->mtime) { 
    219280                p->hits ++; 
    220281                p->atime = XG(request_time); 
     
    474535            add_assoc_long_ex(ei, ZEND_STRS("sourcesize"),    php->sourcesize); 
    475536#ifdef HAVE_INODE 
    476             add_assoc_long_ex(ei, ZEND_STRS("device"),        php->device); 
    477             add_assoc_long_ex(ei, ZEND_STRS("inode"),         php->inode); 
    478 #endif 
    479             add_assoc_long_ex(ei, ZEND_STRS("mtime"),         php->mtime); 
     537            add_assoc_long_ex(ei, ZEND_STRS("device"),        entry->device); 
     538            add_assoc_long_ex(ei, ZEND_STRS("inode"),         entry->inode); 
     539#endif 
     540            add_assoc_long_ex(ei, ZEND_STRS("mtime"),         entry->mtime); 
    480541 
    481542#ifdef HAVE_XCACHE_CONSTANT 
     
    644705        if (VCWD_STAT(filepath, pbuf) == 0) { 
    645706            free_alloca(paths); 
    646             return 0; 
     707            return FAILURE; 
    647708        } 
    648709    } 
     
    650711    free_alloca(paths); 
    651712 
    652     return 1; 
     713    return SUCCESS; 
    653714} 
    654715/* }}} */ 
     
    656717#define HASH(i) (i) 
    657718#define HASH_USTR_L(t, s, l) HASH(zend_u_inline_hash_func(t, s, (l + 1) * sizeof(UChar))) 
    658 #define HASH_STR_L(s, l) HASH(zend_inline_hash_func(s, l + 1)) 
     719#define HASH_STR_S(s, l) HASH(zend_inline_hash_func(s, l)) 
     720#define HASH_STR_L(s, l) HASH_STR_S(s, l + 1) 
    659721#define HASH_STR(s) HASH_STR_L(s, strlen(s) + 1) 
    660722#define HASH_NUM(n) HASH(n) 
     
    669731{ 
    670732#ifdef HAVE_INODE 
    671     if (xce->data.php->inode) { 
    672         return HASH(xce->data.php->device + xce->data.php->inode); 
     733    if (xce->inode) { 
     734        return HASH(xce->device + xce->inode); 
    673735    } 
    674736#endif 
     
    685747 
    686748    if (!filename || !SG(request_info).path_translated) { 
    687         return 0; 
     749        return FAILURE; 
    688750    } 
    689751 
     
    703765        if (IS_ABSOLUTE_PATH(filename, strlen(filename))) { 
    704766            if (VCWD_STAT(filename, pbuf) != 0) { 
    705                 return 0; 
     767                return FAILURE; 
    706768            } 
    707769            goto stat_done; 
     
    719781 
    720782            if (VCWD_STAT(filename, pbuf) != 0) { 
    721                 return 0; 
     783                return FAILURE; 
    722784            } 
    723785            goto stat_done; 
     
    726788 
    727789        /* use include_path */ 
    728         if (xc_stat(filename, PG(include_path), pbuf TSRMLS_CC) != 0) {    
    729             return 0; 
     790        if (xc_stat(filename, PG(include_path), pbuf TSRMLS_CC) != SUCCESS) { 
     791            return FAILURE; 
    730792        } 
    731793 
     
    734796stat_done: 
    735797        if (XG(request_time) - pbuf->st_mtime < 2 && !xc_test) { 
    736             return 0; 
    737         } 
    738  
    739         php->mtime        = pbuf->st_mtime; 
     798            return FAILURE; 
     799        } 
     800 
     801        xce->mtime        = pbuf->st_mtime; 
    740802#ifdef HAVE_INODE 
    741         php->device       = pbuf->st_dev; 
    742         php->inode        = pbuf->st_ino; 
     803        xce->device       = pbuf->st_dev; 
     804        xce->inode        = pbuf->st_ino; 
    743805#endif 
    744806        php->sourcesize   = pbuf->st_size; 
    745807    } 
    746808    else { /* XG(inode) */ 
    747         php->mtime        = 0; 
     809        xce->mtime        = 0; 
    748810#ifdef HAVE_INODE 
    749         php->device       = 0; 
    750         php->inode        = 0; 
     811        xce->device       = 0; 
     812        xce->inode        = 0; 
    751813#endif 
    752814        php->sourcesize   = 0; 
     
    754816 
    755817#ifdef HAVE_INODE 
    756     if (!php->inode) 
     818    if (!xce->inode) 
    757819#endif 
    758820    { 
     
    760822        filename = expand_filepath(filename, opened_path_buffer TSRMLS_CC); 
    761823        if (filename == NULL) { 
    762             return 0; 
     824            return FAILURE; 
    763825        } 
    764826    } 
     
    775837 
    776838    xce->type = XC_TYPE_PHP; 
    777     return 1; 
     839    return SUCCESS; 
     840} 
     841/* }}} */ 
     842static inline xc_hash_value_t xc_php_hash_md5(xc_entry_data_php_t *php TSRMLS_DC) /* {{{ */ 
     843{ 
     844    return HASH_STR_S(php->md5, sizeof(php->md5)); 
     845} 
     846/* }}} */ 
     847static int xc_entry_init_key_php_md5(xc_entry_data_php_t *php, xc_entry_t *xce TSRMLS_DC) /* {{{ */ 
     848{ 
     849    unsigned char   buf[1024]; 
     850    PHP_MD5_CTX     context; 
     851    int             n; 
     852    php_stream     *stream; 
     853    xc_hash_value_t hv; 
     854 
     855    stream = php_stream_open_wrapper(xce->name.str.val, "rb", REPORT_ERRORS | ENFORCE_SAFE_MODE, NULL); 
     856    if (!stream) { 
     857        return FAILURE; 
     858    } 
     859 
     860    PHP_MD5Init(&context); 
     861    while ((n = php_stream_read(stream, (char *) buf, sizeof(buf))) > 0) { 
     862        PHP_MD5Update(&context, buf, n); 
     863    } 
     864    PHP_MD5Final((unsigned char *) php->md5, &context); 
     865 
     866    php_stream_close(stream); 
     867 
     868    if (n < 0) { 
     869        return FAILURE; 
     870    } 
     871 
     872    hv = xc_php_hash_md5(php TSRMLS_CC); 
     873    php->cache  = xce->cache; 
     874    php->hvalue = (hv & php->cache->hphp->mask); 
     875#ifdef DEBUG 
     876    { 
     877        char md5str[33]; 
     878        make_digest(md5str, (unsigned char *) php->md5); 
     879        TRACE("md5 %s", md5str); 
     880    } 
     881#endif 
     882 
     883    return SUCCESS; 
    778884} 
    779885/* }}} */ 
     
    805911} 
    806912/* }}} */ 
    807 static zend_op_array *xc_compile_file(zend_file_handle *h, int type TSRMLS_DC) /* {{{ */ 
    808 { 
    809     xc_sandbox_t sandbox; 
     913static void xc_free_php(xc_entry_data_php_t *php TSRMLS_DC) /* {{{ */ 
     914{ 
     915#define X_FREE(var) do {\ 
     916    if (php->var) { \ 
     917        efree(php->var); \ 
     918    } \ 
     919} while (0) 
     920 
     921#ifdef ZEND_ENGINE_2_1 
     922    X_FREE(autoglobals); 
     923#endif 
     924    X_FREE(classinfos); 
     925    X_FREE(funcinfos); 
     926#ifdef HAVE_XCACHE_CONSTANT 
     927    X_FREE(constinfos); 
     928#endif 
     929#undef X_FREE 
     930} 
     931/* }}} */ 
     932static zend_op_array *xc_compile_php(xc_entry_data_php_t *php, zend_file_handle *h, int type TSRMLS_DC) /* {{{ */ 
     933{ 
    810934    zend_op_array *op_array; 
    811     xc_entry_t xce, *stored_xce; 
    812     xc_entry_data_php_t php; 
    813     xc_cache_t *cache; 
    814     zend_bool clogged = 0; 
    815     zend_bool catched = 0; 
    816     char *filename; 
    817     char opened_path_buffer[MAXPATHLEN]; 
    818935    int old_constinfo_cnt, old_funcinfo_cnt, old_classinfo_cnt; 
    819936    int i; 
    820  
    821     if (!xc_initized) { 
    822         assert(0); 
    823     } 
    824  
    825     if (!XG(cacher)) { 
    826         op_array = origin_compile_file(h, type TSRMLS_CC); 
    827 #ifdef HAVE_XCACHE_OPTIMIZER 
    828         if (XG(optimizer)) { 
    829             xc_optimize(op_array TSRMLS_CC); 
    830         } 
    831 #endif 
    832         return op_array; 
    833     } 
    834  
    835     /* {{{ prepare key 
    836      * include_once() and require_once() gives us opened_path 
    837      * however, include() and require() non-absolute path which break 
    838      * included_files, and may confuse with (include|require)_once 
    839      * -- Xuefer 
    840      */ 
    841  
    842     filename = h->opened_path ? h->opened_path : h->filename; 
    843     xce.data.php = &php; 
    844     if (!xc_entry_init_key_php(&xce, filename, opened_path_buffer TSRMLS_CC)) { 
    845         return origin_compile_file(h, type TSRMLS_CC); 
    846     } 
    847     cache = xce.cache; 
    848     /* }}} */ 
    849     /* {{{ restore */ 
    850     /* stale precheck */ 
    851     if (cache->compiling) { 
    852         cache->clogs ++; /* is it safe here? */ 
    853         return origin_compile_file(h, type TSRMLS_CC); 
    854     } 
    855  
    856     stored_xce = NULL; 
    857     op_array = NULL; 
    858     ENTER_LOCK_EX(cache) { 
    859         /* clogged */ 
    860         if (cache->compiling) { 
    861             cache->clogs ++; 
    862             op_array = NULL; 
    863             clogged = 1; 
    864             break; 
    865         } 
    866  
    867         stored_xce = xc_entry_find_dmz(&xce TSRMLS_CC); 
    868         /* found */ 
    869         if (stored_xce) { 
    870             TRACE("found %s, catch it", stored_xce->name.str.val); 
    871             xc_entry_hold_php_dmz(stored_xce TSRMLS_CC); 
    872             cache->hits ++; 
    873             break; 
    874         } 
    875  
    876         cache->compiling = XG(request_time); 
    877         cache->misses ++; 
    878     } LEAVE_LOCK_EX(cache); 
    879  
    880     if (catched) { 
    881         cache->compiling = 0; 
    882         zend_bailout(); 
    883     } 
    884  
    885     /* found */ 
    886     if (stored_xce) { 
    887         goto restore; 
    888     } 
    889  
    890     /* clogged */ 
    891     if (clogged) { 
    892         return origin_compile_file(h, type TSRMLS_CC); 
    893     } 
    894     /* }}} */ 
     937    zend_bool catched = 0; 
    895938 
    896939    /* {{{ compile */ 
    897     TRACE("compiling %s", filename); 
    898  
    899     /* make compile inside sandbox */ 
    900     xc_sandbox_init(&sandbox, filename TSRMLS_CC); 
     940    TRACE("compiling %s", h->opened_path ? h->opened_path : h->filename); 
    901941 
    902942    old_classinfo_cnt = zend_hash_num_elements(CG(class_table)); 
     
    915955 
    916956    if (op_array == NULL) { 
    917         goto err_oparray; 
    918