Changeset 1045 for trunk/xcache.c


Ignore:
Timestamp:
2012-07-25T11:32:11+02:00 (21 months ago)
Author:
moo
Message:

refactor: bring back compatibility with Zend Optimizer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xcache.c

    r1040 r1045  
    3939 
    4040static zend_compile_file_t *old_compile_file = NULL; 
    41 static zend_llist_element  *xc_llist_zend_extension = NULL; 
    4241 
    4342zend_bool xc_test = 0; 
     
    544543#endif 
    545544 
    546 static startup_func_t xc_last_ext_startup; 
     545static startup_func_t xc_last_ext_old_startup; 
     546static xc_stack_t xc_llist_zend_extensions; /* (zend_extension *) */ 
    547547static int xc_zend_startup_last_hook(zend_extension *extension) /* {{{ */ 
    548548{ 
     
    552552    } 
    553553    /* restore */ 
    554     extension->startup = xc_last_ext_startup; 
     554    extension->startup = xc_last_ext_old_startup; 
     555    extension->startup = xc_last_ext_old_startup; 
     556    xc_last_ext_old_startup = NULL; 
    555557    if (extension->startup) { 
    556558        if (extension->startup(extension) != SUCCESS) { 
     
    558560        } 
    559561    } 
    560     assert(xc_llist_zend_extension); 
    561     xcache_llist_prepend(&zend_extensions, xc_llist_zend_extension); 
     562 
     563    assert(xc_stack_count(&xc_llist_zend_extensions)); 
     564    while (xc_stack_count(&xc_llist_zend_extensions)) { 
     565        zend_llist_element *p = (zend_llist_element *) xc_stack_pop(&xc_llist_zend_extensions); 
     566        xcache_llist_prepend(&zend_extensions, p); 
     567    } 
     568    xc_stack_destroy(&xc_llist_zend_extensions); 
    562569    return SUCCESS; 
    563570} 
     
    568575    zend_compile_file = xc_check_initial_compile_file; 
    569576 
    570     if (zend_llist_count(&zend_extensions) > 1) { 
     577    if (1 || xcache_zend_extension_count_by_prefix(&zend_extensions, XCACHE_NAME) != zend_llist_count(&zend_extensions)) { 
    571578        zend_llist_position lpos; 
    572         zend_extension *ext; 
    573  
    574         xc_llist_zend_extension = xcache_llist_get_element_by_zend_extension(&zend_extensions, XCACHE_NAME); 
    575         if (xc_llist_zend_extension != zend_extensions.head) { 
    576             zend_error(E_WARNING, "XCache failed to load itself as the first zend_extension. compatibility downgraded"); 
    577         } 
    578  
    579         /* hide myself */ 
    580         /* TODO: hide handle sub modules */ 
    581         xcache_llist_unlink(&zend_extensions, xc_llist_zend_extension); 
     579        zend_extension *ext = (zend_extension *) zend_extensions.head->data; 
     580        assert(ext); 
     581 
     582        if (strcmp(ext->name, XCACHE_NAME) != 0) { 
     583            zend_error(E_WARNING, "XCache failed to load itself as the before \"%s\". compatibility downgraded", ext->name); 
     584        } 
     585 
     586        /* hide XCache modules */ 
     587        xc_stack_init(&xc_llist_zend_extensions); 
     588        xcache_zend_extension_unlink_by_prefix(&xc_llist_zend_extensions, &zend_extensions, XCACHE_NAME); 
    582589 
    583590        ext = (zend_extension *) zend_llist_get_last_ex(&zend_extensions, &lpos); 
    584         assert(ext && ext != (zend_extension *) xc_llist_zend_extension->data); 
    585         xc_last_ext_startup = ext->startup; 
     591        assert(ext); 
     592        xc_last_ext_old_startup = ext->startup; 
    586593        ext->startup = xc_zend_startup_last_hook; 
    587594    } 
     
    638645static PHP_MINIT_FUNCTION(xcache) /* {{{ */ 
    639646{ 
    640     /* must be the first */ 
    641     xcache_zend_extension_register(&xc_zend_extension_entry, 1); 
    642  
    643647#ifndef PHP_GINIT 
    644648    ZEND_INIT_MODULE_GLOBALS(xcache, xc_init_globals, xc_shutdown_globals); 
     
    653657    xc_shm_init_modules(); 
    654658 
     659    /* ZendExtension is registered in reverse order for prepend by XCache */ 
     660#ifdef HAVE_XCACHE_COVERAGER 
     661    xc_coverager_startup_module(); 
     662#endif 
     663#ifdef HAVE_XCACHE_DISASSEMBLER 
     664    xc_disassembler_startup_module(); 
     665#endif 
     666#ifdef HAVE_XCACHE_CACHER 
     667    xc_cacher_startup_module(); 
     668#endif 
    655669#ifdef HAVE_XCACHE_OPTIMIZER 
    656670    xc_optimizer_startup_module(); 
    657671#endif 
    658 #ifdef HAVE_XCACHE_CACHER 
    659     xc_cacher_startup_module(); 
    660 #endif 
    661 #ifdef HAVE_XCACHE_COVERAGER 
    662     xc_coverager_startup_module(); 
    663 #endif 
    664 #ifdef HAVE_XCACHE_DISASSEMBLER 
    665     xc_disassembler_startup_module(); 
    666 #endif 
     672    /* must be the first */ 
     673    xcache_zend_extension_prepend(&xc_zend_extension_entry); 
     674 
    667675    return SUCCESS; 
    668676 
     
    694702 
    695703    UNREGISTER_INI_ENTRIES(); 
    696     xcache_zend_extension_unregister(&xc_zend_extension_entry); 
     704    xcache_zend_extension_remove(&xc_zend_extension_entry); 
    697705    return SUCCESS; 
    698706} 
Note: See TracChangeset for help on using the changeset viewer.