Changeset 278 in svn for trunk/xcache.c


Ignore:
Timestamp:
2006-11-17T17:21:46Z (9 years ago)
Author:
Xuefer
Message:

trunk: fix coredump on shutdown when loaded as "extension" and after "suhosin". thanks to Alex, Cristian and Esser

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xcache.c

    r268 r278  
    107107static zend_bool xc_module_gotup = 0;
    108108static zend_bool xc_zend_extension_gotup = 0;
     109static zend_bool xc_zend_extension_faked = 0;
    109110#if !COMPILE_DL_XCACHE
    110111#   define zend_extension_entry xcache_zend_extension_entry
     
    23812382}
    23822383/* }}} */
     2384static int xc_ptr_compare_func(void *p1, void *p2) /* {{{ */
     2385{
     2386    return p1 == p2;
     2387}
     2388/* }}} */
     2389static int xc_zend_remove_extension(zend_extension *extension) /* {{{ */
     2390{
     2391    llist_dtor_func_t dtor;
     2392
     2393    assert(extension);
     2394    dtor = zend_extensions.dtor; /* avoid dtor */
     2395    zend_extensions.dtor = NULL;
     2396    zend_llist_del_element(&zend_extensions, extension, xc_ptr_compare_func);
     2397    zend_extensions.dtor = dtor;
     2398}
     2399/* }}} */
    23832400static int xc_config_hash(xc_hash_t *p, char *name, char *default_value) /* {{{ */
    23842401{
     
    24252442            xc_zend_extension_register(&zend_extension_entry, 0);
    24262443            xc_zend_extension_startup(&zend_extension_entry);
     2444            xc_zend_extension_faked = 1;
    24272445        }
    24282446    }
     
    25342552#endif
    25352553
     2554    if (xc_zend_extension_faked) {
     2555        zend_extension *ext = zend_get_extension(XCACHE_NAME);
     2556        if (ext->shutdown) {
     2557            ext->shutdown(ext);
     2558        }
     2559        xc_zend_remove_extension(ext);
     2560    }
    25362561    UNREGISTER_INI_ENTRIES();
    25372562    return SUCCESS;
     
    25962621static startup_func_t xc_last_ext_startup;
    25972622static zend_llist_element *xc_llist_element;
    2598 static int xc_ptr_compare_func(void *p1, void *p2) /* {{{ */
    2599 {
    2600     return p1 == p2;
    2601 }
    2602 /* }}} */
    26032623static int xc_zend_startup_last(zend_extension *extension) /* {{{ */
    26042624{
     
    26272647        zend_llist_position lpos;
    26282648        zend_extension *ext;
    2629         llist_dtor_func_t dtor;
    26302649
    26312650        ext = zend_get_extension(XCACHE_NAME);
    2632         assert(ext);
    2633         dtor = zend_extensions.dtor; /* avoid dtor */
    2634         zend_extensions.dtor = NULL;
    2635         zend_llist_del_element(&zend_extensions, ext, xc_ptr_compare_func);
    2636         zend_extensions.dtor = dtor;
     2651        xc_zend_remove_extension(ext);
    26372652
    26382653        ext = (zend_extension *) zend_llist_get_last_ex(&zend_extensions, &lpos);
Note: See TracChangeset for help on using the changeset viewer.