Changeset 1177 in svn for trunk


Ignore:
Timestamp:
2012-11-13T15:28:28+01:00 (3 years ago)
Author:
Xuefer
Message:

better compatibility using exception list instead of empty list to startup incompatible extension

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xcache.c

    r1172 r1177  
    564564    { "the ionCube PHP Loader", NULL }
    565565};
     566zend_llist_element **xc_zend_extension_elements;
    566567
    567568static xc_incompatible_zend_extension_info_t *xc_get_incompatible_zend_extension_info(const char *name)
     
    579580}
    580581/* }}} */
     582static void xc_zend_llist_add_element(zend_llist *list, zend_llist_element *element) /* {{{ */
     583{
     584    if (!zend_extensions.head) {
     585        zend_extensions.head = zend_extensions.tail = element;
     586    }
     587    else {
     588        zend_extensions.tail->next = element;
     589        element->prev = zend_extensions.tail;
     590        zend_extensions.tail = element;
     591    }
     592}
     593/* }}} */
    581594static int xc_incompatible_zend_extension_startup_hook(zend_extension *extension) /* {{{ */
    582595{
     
    584597    int status;
    585598    zend_bool catched = 0;
    586     zend_llist old_zend_extensions = zend_extensions;
    587 #if TODO
    588     zend_llist_position lpos;
     599    zend_llist old_zend_extensions;
    589600    zend_extension *ext;
    590 #endif
     601    size_t i;
     602    zend_llist_element *element;
    591603    TSRMLS_FETCH();
    592604
     
    596608    assert(extension->startup);
    597609
    598     /* hide all extensions from it */
     610    /* save */
     611    assert(!xc_zend_extension_elements);
     612    old_zend_extensions = zend_extensions;
     613    xc_zend_extension_elements = malloc(sizeof(zend_llist_element *) * old_zend_extensions.count);
     614    for (i = 0, element = old_zend_extensions.head; element; ++i, element = element->next) {
     615        xc_zend_extension_elements[i] = element;
     616    }
     617
     618    /* hide all XCache extensions from it */
    599619    zend_extensions.head = NULL;
    600620    zend_extensions.tail = NULL;
    601621    zend_extensions.count = 0;
    602     zend_extensions.dtor = NULL;
    603 #if TODO
    604     for (ext = (zend_extension *) zend_llist_get_first_ex(&old_zend_extensions, &lpos);
    605             ext;
    606             ext = (zend_extension *) zend_llist_get_next_ex(&old_zend_extensions, &lpos)) {
     622
     623    for (i = 0; i < old_zend_extensions.count; ++i) {
     624        element = xc_zend_extension_elements[i];
     625        element->next = element->prev = NULL;
     626
     627        ext = (zend_extension *) element->data;
     628
    607629        if (!(strcmp(ext->name, XCACHE_NAME) == 0 || strncmp(ext->name, XCACHE_NAME " ", sizeof(XCACHE_NAME " ") - 1) == 0)) {
    608             zend_llist_add_element(&zend_extensions, ext);
    609         }
    610     }
    611 #endif
    612     zend_llist_add_element(&zend_extensions, extension);
    613     extension = zend_get_extension(extension->name);
     630            xc_zend_llist_add_element(&zend_extensions, element);
     631            ++zend_extensions.count;
     632        }
     633    }
    614634
    615635    assert(extension->startup != xc_incompatible_zend_extension_startup_hook);
     
    621641
    622642    /* restore */
    623     zend_llist_destroy(&zend_extensions);
    624643    zend_extensions = old_zend_extensions;
     644    zend_extensions.head = NULL;
     645    zend_extensions.tail = NULL;
     646    zend_extensions.count = 0;
     647    for (i = 0; i < old_zend_extensions.count; ++i) {
     648        element = xc_zend_extension_elements[i];
     649        element->next = element->prev = NULL;
     650
     651        xc_zend_llist_add_element(&zend_extensions, element);
     652        ++zend_extensions.count;
     653    }
     654
     655    free(xc_zend_extension_elements);
     656    xc_zend_extension_elements = NULL;
     657
    625658    if (catched) {
    626659        zend_bailout();
Note: See TracChangeset for help on using the changeset viewer.