Changeset 1251 for trunk


Ignore:
Timestamp:
2013-05-27T16:58:08+02:00 (2 years ago)
Author:
moo
Message:

fixes #307: compatible with Zend Debugger which requires to be installed after Zend Extension Manager

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r1245 r1251  
    1212 * fixes #296: Multiple instances of the same software causes PHP "cannot redeclare class" errors when readonly_protection is not in use
    1313 * fixes #301: refix locking impl
     14 * fixes #307: compatible with Zend Debugger which requires to be installed after Zend Extension Manager
    1415
    15163.0.1 2013-01-11
  • trunk/NEWS

    r1238 r1251  
    88 * bug fixes
    99 * "cannot redeclare class" errors is now gone. Can also be avoid by using readonly_protection (unavailable with /dev/zero).
     10 * fixes SEGV with Zend Debugger
    1011
    11123.0.1 2013-01-11
  • trunk/xcache.c

    r1230 r1251  
    5656}
    5757/* }}} */
     58
     59/* devel helper function */
     60#if 0
     61static void xc_list_extensions() /* {{{ */
     62{
     63    zend_llist_element *element;
     64    zend_extension *ext;
     65    fprintf(stderr, "extensions:\n");
     66    for (element = zend_extensions.head; element; element = element->next) {
     67        ext = (zend_extension *) element->data;
     68        fprintf(stderr, " - %s\n", ext->name);
     69    }
     70}
     71/* }}} */
     72#endif
    5873
    5974/* module helper function */
     
    567582} xc_incompatible_zend_extension_info_t;
    568583static xc_incompatible_zend_extension_info_t xc_incompatible_zend_extensions[] = {
     584    { "Zend Extension Manager", NULL },
    569585    { "Zend Optimizer", NULL },
    570586    { "the ionCube PHP Loader", NULL }
    571587};
    572 zend_llist_element **xc_zend_extension_elements;
    573588
    574589static xc_incompatible_zend_extension_info_t *xc_get_incompatible_zend_extension_info(const char *name)
     
    603618    int status;
    604619    zend_bool catched = 0;
    605     zend_llist old_zend_extensions;
     620    zend_llist saved_zend_extensions_container; /* without elements */
     621    zend_llist_element **saved_zend_extensions_elments;
     622    size_t new_zend_extensions_elments_count;
     623    zend_llist_element **new_zend_extensions_elments;
    606624    zend_extension *ext;
    607625    size_t i;
     
    609627    TSRMLS_FETCH();
    610628
    611     /* restore */
     629    /* restore startup hack */
    612630    extension->startup = incompatible_zend_extension_info->old_startup;
    613631    incompatible_zend_extension_info->old_startup = NULL;
    614632    assert(extension->startup);
    615633
    616     /* save */
    617     assert(!xc_zend_extension_elements);
    618     old_zend_extensions = zend_extensions;
    619     xc_zend_extension_elements = malloc(sizeof(zend_llist_element *) * old_zend_extensions.count);
    620     for (i = 0, element = old_zend_extensions.head; element; ++i, element = element->next) {
    621         xc_zend_extension_elements[i] = element;
     634    /* save extensions list */
     635    saved_zend_extensions_container = zend_extensions;
     636    saved_zend_extensions_elments = malloc(sizeof(zend_llist_element *) * saved_zend_extensions_container.count);
     637    for (i = 0, element = saved_zend_extensions_container.head; element; ++i, element = element->next) {
     638        saved_zend_extensions_elments[i] = element;
    622639    }
    623640
     
    627644    zend_extensions.count = 0;
    628645
    629     for (i = 0; i < old_zend_extensions.count; ++i) {
    630         element = xc_zend_extension_elements[i];
     646    for (i = 0; i < saved_zend_extensions_container.count; ++i) {
     647        element = saved_zend_extensions_elments[i];
    631648        element->next = element->prev = NULL;
    632649
     
    646663    } zend_end_try();
    647664
    648     /* restore */
    649     zend_extensions = old_zend_extensions;
     665    /* save newly added extensions added by this extension*/
     666    new_zend_extensions_elments_count = zend_extensions.count - 1;
     667    new_zend_extensions_elments = NULL;
     668    if (new_zend_extensions_elments_count) {
     669        new_zend_extensions_elments = malloc(sizeof(zend_llist_element *) * new_zend_extensions_elments_count);
     670        element = zend_extensions.head;
     671        for (i = 0, element = element->next; element; ++i, element = element->next) {
     672            new_zend_extensions_elments[i] = element;
     673        }
     674    }
     675
     676    /* restore original extension list*/
     677    zend_extensions = saved_zend_extensions_container;
    650678    zend_extensions.head = NULL;
    651679    zend_extensions.tail = NULL;
    652680    zend_extensions.count = 0;
    653     for (i = 0; i < old_zend_extensions.count; ++i) {
    654         element = xc_zend_extension_elements[i];
     681    for (i = 0; i < saved_zend_extensions_container.count; ++i) {
     682        element = saved_zend_extensions_elments[i];
    655683        element->next = element->prev = NULL;
    656684
    657685        xc_zend_llist_add_element(&zend_extensions, element);
    658686        ++zend_extensions.count;
    659     }
    660 
    661     free(xc_zend_extension_elements);
    662     xc_zend_extension_elements = NULL;
     687
     688        ext = (zend_extension *) element->data;
     689        if (ext == extension && new_zend_extensions_elments_count) {
     690            /* add new created extension */
     691            size_t j;
     692            for (j = 0; j < new_zend_extensions_elments_count; ++j) {
     693                element = new_zend_extensions_elments[j];
     694                element->next = element->prev = NULL;
     695
     696                xc_zend_llist_add_element(&zend_extensions, element);
     697                ++zend_extensions.count;
     698            }
     699        }
     700    }
     701    free(saved_zend_extensions_elments);
     702    if (new_zend_extensions_elments) {
     703        free(new_zend_extensions_elments);
     704    }
    663705
    664706    if (catched) {
Note: See TracChangeset for help on using the changeset viewer.