zend_bool active;
zend_bool valid_symbol_table;
+ zend_uchar flags;
zend_long assertions;
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
};
+#define EG_FLAGS_INITIAL 0x00
+#define EG_FLAGS_IN_SHUTDOWN 0x01
+
struct _zend_ini_scanner_globals {
zend_file_handle *yy_in;
zend_file_handle *yy_out;
#include "zend_API.h"
#include "zend_objects_API.h"
-ZEND_TLS zend_objects_store_no_reuse; /* Would make more sense to make it a member of zend_objects_store, defining as a global to not break alignments */
-
ZEND_API void zend_objects_store_init(zend_objects_store *objects, uint32_t init_size)
{
objects->object_buckets = (zend_object **) emalloc(init_size * sizeof(zend_object*));
objects->top = 1; /* Skip 0 so that handles are true */
objects->size = init_size;
objects->free_list_head = -1;
- zend_objects_store_no_reuse = 0;
memset(&objects->object_buckets[0], 0, sizeof(zend_object*));
}
ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects)
{
- zend_objects_store_no_reuse = 1; /* new objects spawned by dtors will never reuse unused slots, so their own dtors will be called further down the loop */
if (objects->top > 1) {
uint32_t i;
for (i = 1; i < objects->top; i++) {
{
int handle;
- if (!zend_objects_store_no_reuse && EG(objects_store).free_list_head != -1) {
+ /* When in shutdown sequesnce - do not reuse previously freed handles, to make sure
+ * the dtors for newly created objects are called in zend_objects_store_call_destructors() loop
+ */
+ if (!(EG(flags) & EG_FLAGS_IN_SHUTDOWN) && EG(objects_store).free_list_head != -1) {
handle = EG(objects_store).free_list_head;
EG(objects_store).free_list_head = GET_OBJ_BUCKET_NUMBER(EG(objects_store).object_buckets[handle]);
} else {
void php_request_shutdown(void *dummy)
{
zend_bool report_memleaks;
+
+ EG(flags) |= EG_FLAGS_IN_SHUTDOWN;
report_memleaks = PG(report_memleaks);