Skip to content

Commit

Permalink
Merge branch 'pull-request/770' into PHP-5.4
Browse files Browse the repository at this point in the history
* pull-request/770:
  Only destruct if EG(active) in zend_shutdown(). (bug #65463, #66036)
  Fix typo from commit 32314f6
  Fix destruction order in zend_shutdown (bug #65463, #66036)
  • Loading branch information
smalyshev committed Sep 1, 2014
2 parents e665a07 + 437612f commit 197095c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
14 changes: 14 additions & 0 deletions Zend/zend.c
Expand Up @@ -813,6 +813,20 @@ void zend_shutdown(TSRMLS_D) /* {{{ */
zend_shutdown_timeout_thread();
#endif
zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC);

if (EG(active))
{
/*
* The order of destruction is important here.
* See bugs #65463 and 66036.
*/
zend_hash_reverse_apply(GLOBAL_FUNCTION_TABLE, (apply_func_t) zend_cleanup_function_data_full TSRMLS_CC);
zend_hash_reverse_apply(GLOBAL_CLASS_TABLE, (apply_func_t) zend_cleanup_user_class_data TSRMLS_CC);
zend_cleanup_internal_classes(TSRMLS_C);
zend_hash_reverse_apply(GLOBAL_FUNCTION_TABLE, (apply_func_t) clean_non_persistent_function_full TSRMLS_CC);
zend_hash_reverse_apply(GLOBAL_CLASS_TABLE, (apply_func_t) clean_non_persistent_class_full TSRMLS_CC);
}

zend_destroy_modules();

zend_hash_destroy(GLOBAL_FUNCTION_TABLE);
Expand Down
2 changes: 2 additions & 0 deletions Zend/zend_compile.h
Expand Up @@ -639,6 +639,8 @@ ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce TSRMLS_DC);
ZEND_API void zend_cleanup_internal_classes(TSRMLS_D);
ZEND_API int zend_cleanup_function_data(zend_function *function TSRMLS_DC);
ZEND_API int zend_cleanup_function_data_full(zend_function *function TSRMLS_DC);
ZEND_API int clean_non_persistent_function_full(zend_function *function TSRMLS_DC);
ZEND_API int clean_non_persistent_class_full(zend_class_entry **ce TSRMLS_DC);

ZEND_API void destroy_zend_function(zend_function *function TSRMLS_DC);
ZEND_API void zend_function_dtor(zend_function *function);
Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_execute_API.c
Expand Up @@ -108,7 +108,7 @@ static int clean_non_persistent_function(zend_function *function TSRMLS_DC) /* {
}
/* }}} */

static int clean_non_persistent_function_full(zend_function *function TSRMLS_DC) /* {{{ */
ZEND_API int clean_non_persistent_function_full(zend_function *function TSRMLS_DC) /* {{{ */
{
return (function->type == ZEND_INTERNAL_FUNCTION) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE;
}
Expand All @@ -120,7 +120,7 @@ static int clean_non_persistent_class(zend_class_entry **ce TSRMLS_DC) /* {{{ */
}
/* }}} */

static int clean_non_persistent_class_full(zend_class_entry **ce TSRMLS_DC) /* {{{ */
ZEND_API int clean_non_persistent_class_full(zend_class_entry **ce TSRMLS_DC) /* {{{ */
{
return ((*ce)->type == ZEND_INTERNAL_CLASS) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE;
}
Expand Down

0 comments on commit 197095c

Please sign in to comment.